How to use for loop and add one day (timedelta) every time

Viewed 6092

Here is my code:

import datetime

date = datetime.date(2015,10,1)
today = datetime..today()
oneday = datetime.timedelta(days = 1)

date_counter = 0
while not date == today:
    date_counter+=1
    date += oneday

In this code I use while loop to achieve my goal--to count the days between today and the specific day chosen by users.

However, I want to use for loop to do the same thing. Can it rewrite by for?

5 Answers
Related