dimanche 21 novembre 2021

Pyhon multiple possibilities in if statment

Can I make one if statement with more options so I don't need to make twelve of them? I am new to python and I have an assignment to print month names with corresponding numbers. Normally it would be:

if month == 1
   print(one) # one = January

Can I make it something like :

if month == [1,2,3,4,5,6]
   print [one,two.three, etc.]

I tried it and it does not work, but I am wondering if it is possible?

Aucun commentaire:

Enregistrer un commentaire