vendredi 26 février 2021

Conditional statement shortcut (python)

I cannot find where my professor taught us to do this. For a conditional statement, if there are multiple numbers ("if x = 1 or 3 or 5 or 9 or ......), how do I make it shorter so I dont have to type every single one? I thought it was the in function???

this is what exactly im trying to do:

elif month == 1 and day == in[4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 24, 25, 26, 27, 28, 29, 30]: print("January", day + "th", year, "is a valid date")

Aucun commentaire:

Enregistrer un commentaire