mercredi 7 novembre 2018

Writing a program for days in months

So I'm trying to write a code where whatever number of the month it is, it returns me the number of days there are in this month. Here is the code I have written at the moment. I got some of the months right but the rest aren't. Can someone point out what I did wrong with the coding?

def get_days_in_month (month):
if (month == 2):
    return 28
elif (month == 4 + 6 + 9 + 11):
    return 30
elif (month == 1 + 3 + 5 + 7 + 8 + 10 +12):
    return 31
else:
    return 31

Aucun commentaire:

Enregistrer un commentaire