If you want to print out a list of all dates between 2 dates (a date range), then you can use the following script:
from datetime import date, timedelta
start_date = date(2021, 5, 31)
end_date = date(2021, 7, 28)
delta = end_date - start_date
for i in range(delta.days + 1):
day = start_date + timedelta(days=i)
print(day)
This will result in the following range:
2021-05-31
2021-06-01
...
2021-07-27
2021-07-28
To make sure that you get the format you want back:
day.strftime("%Y-%m-%d")
This date manipulation technique is useful for many Python applications. If you’re interested in other Python challenges involving numerical sequences, you might want to check out getting the next biggest number with the same digits using Python .