is it possible to create a looping list?
import time
# a day value of None = >
def dayOfWeek(DayNum = None):
# match day order to Python return values
days = ['Monday','Tuesday',
'Wednesday','Thursday',
'Friday','Saturday','Sunday']
theTime = time.localtime(time.time())
# Check for default value
if DayNum == None:
Day = theTime[6] # extract the day value
elif DayNum == 1 or 2 or 3 or 4 or 5 or 6 :
today = theTime[6]
Day = today + DayNum
else:
print "That is not a valid choice"
return days[Day]
This is the code I have made. It aims to produce the name of the day of the week basing everything on the time module. It is called through dayOfWeek().
I would like to know if it was possible to create a looping list...that is to say if today was Wednesday.. i would type dayOfWeek() and it would return Wednesday.. but say I wanted to know the name of the day in 20 days..if i write dayOfWeek(20) it will give me an error because the list is only day[0:6] How would I do this?
regards,
Jeremy.