I wrote a function that contains a dictionary of abbreviated week days to the full name of the day. I get the proper output day when I type in the abbreviation, but in order to try another abbreviation, I have to retype the function.
I have:
def weekday()
day = input('Enter day abbreviation ' )
days = {'Mo':'Monday','Tu':'Tuesday',
'we':'Wednesday', 'Th':'Thursday',
'Fr':'Friday', 'Sa':'Saturday','Su':Sunday'}
while day in days:
print(days.get(day))
The problem I have is that it prints the full day name over and over again, and instead I want it to print the full day name, then print 'Enter day abbreviation' again.
It should look like this:
>>>weekday():
Enter day abbreviation: Tu
Tuesday
Enter day abbreviation: Su
Sunday
Enter day abbreviation:
...
Instead, I get:
>>>weekday():
Enter day abbreviation: Tu
Tuesday
Tuesday
Tuesday
Tuesday
Tuesday
... # it continues without stopping
I know this is a really simple solution, but I can't figure it out.