Oct-25-2020, 10:40 PM
I have to lists the idea is I'm going to get the day with calendar and datetime lets say for example that today is Wednesday I would like Wednesday to correspond with the numbers list but Wednesday would start at 0 in the numbers list and the rest would follow. that way if I have Tuesday in my text it would index 1. So basically when I grab the day of the week from calendar and datetime I always want the current day to start at 0 on the numbers list. Any help would be greatly appreciated Thank you!
def get_day(text): days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] number = [0, 1, 2, 3, 4, 5, 6] return number[days.index(text)] text = "Wednesday" print(get_day(text))