My task is to define a function weekdays(weekday)
that returns a list of weekdays, starting with the given weekday. It should work like this:
def weekdays(day):
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
i=days.index(day) # get the index of the selected day
d1=days[i:] #get the list from an including this index
d1.extend(days[:i]) # append the list form the beginning to this index
return d1
And if you want to test that it works:
def test_weekdays():
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
for day in days:
print weekdays(day)