Forum Archive

Day of Week Issue

Dann239

So I have a problem. I've thought and thought and googled and googled.

If today is Saturday... I want to set up a list (or possibly dictionary) whereas the order will follow as Saturday, Sunday, Monday, etc. this needs to reapply every time I run the script. That list will end with Friday if I ran it on a Saturday...

I can obviously get the weekday using datetime. How do I apply that? How do I simplify the instruction to create the list?

ccc
import datetime as dt
now = dt.datetime.now()
the_daze = [(now + dt.timedelta(days=i)).strftime('%A') for i in xrange(7)]
print(the_daze)
Dann239

Thank you, ccc.