So I was wondering if there is a way to print the nth value (not the last value) from a For Loop output. For eg: let's suppose I want to print just the 'fifth-to-last' value or just the 'third-to-last' value from the For Loop output. Any idea how can I do that? I am newbie at coding/python and I am building up this code after doing a lot of research & learning on the way. So any help appreciated.
Currently, the code below is giving me the last value.
from datetime import timedelta, date
def daterange(start_date, end_date):
for n in range(int(start_date.day), int((end_date - start_date).days), 90):
yield start_date + timedelta(n)
start_date = date(2016, 1, 1)
end_date = date.today()
for single_date in daterange(start_date, end_date):
x = single_date.strftime("%Y-%m-%d")
print(x)