I'm trying to make a program that is given abbreviations of the days of the week (Mon, Tue, Wed etc.) and replaces these with the full word (Monday, Tuesday, Wednesday). The program creates a list full of strings and outputs it as a string. I have this working except for when something that isn't a day of the week is used. For example, a word that isn't Mon, Tue, Wed etc. (As seen in the code) I want to be able to filter out the unwanted word but don't know how to. Please help.
The code:
days = []
def format_days(days):
days = [d.replace('Mon', 'Monday') for d in days]
days = [d.replace('Tue', 'Tuesday') for d in days]
days = [d.replace('Wed', 'Wednesday') for d in days]
days = [d.replace('Thu', 'Thursday') for d in days]
days = [d.replace('Fri', 'Friday') for d in days]
days = [d.replace('Sat', 'Saturday') for d in days]
days = [d.replace('Sun', 'Sunday') for d in days]
return days
answer = format_days(['Sat', 'Fun', 'Tue', 'Thu'])
print(answer)
# ['Saturday', 'Fun', 'Tuesday', 'Thursday'] <-- This is the output
# ['Saturday', 'Tuesday', 'Thursday'] <-- This is the output I want
I want to be able to filter out 'fun' from the list but the code needs to work for everything that isn't: Mon, Tue, Wed, Thu, Fri, Sat, Sun not just 'fun'
ifstatement?