Python- Trying to find a date in a list

I have a file txt file taht contains all the dates in a year in the mm/dd/yy format. 01/01/20 01/02/20 01/03/20 01/04/20 01/05/20 01/06/20

And I have a today's date from Python code:

current_time = datetime.datetime.now()
date = current_time.strftime("%m/%d/%Y")

When I try to find the list element == date i don't get a match. The code is:

for i in range(0,366):
    if(date==calendarData[i]):
        break
else:
    print(i,end="  ")
    print("date", date, end=" ")
    print(calendarData[i], end="")
    i=i+1

From the console

269  date 09/29/2020  0 9 / 2 6 / 2 0
270  date 09/29/2020  0 9 / 2 7 / 2 0
271  date 09/29/2020  0 9 / 2 8 / 2 0
272  date 09/29/2020  0 9 / 2 9 / 2 0
273  date 09/29/2020  0 9 / 3 0 / 2 0
274  date 09/29/2020  1 0 / 0 1 / 2 0


from Recent Questions - Stack Overflow https://ift.tt/2GfyIo9
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation