jeudi 13 février 2020

Python if-else statement not returning the correct variable value with variable months [duplicate]

This is my first ever question on here and a simple question at that and I apologies for sounding like a noob but I'm confused as to why if month is equal to any month not in the top if statement it still returns 31.

for example when month = "June", date is still returning as 31 instead of 30.

month = "June"

if month == "January" or "March" or "May" or "July" or "August" or "October" or "December":
   date = 31
elif month == "February":
   date = 28
elif month == "April" or "June" or "September" or "November":
   date = 30'
>>> date
31

Aucun commentaire:

Enregistrer un commentaire