mercredi 30 mars 2016

Python IF condition with multiple variables

Could someone clarify this. What happens if I try to write this code:

if tomato = 1 or tomato = 2 or tomato = 3

... like this:

if tomato = 1 or 2 or 3 

I know Python doesn't consider it the same but what does it think I'm doing?

Most importantly, what's the best way to do this if I have a whole bunch of conditions for tomato. Writing "tomato =" each time doesn't seem very neat. Thank you

Aucun commentaire:

Enregistrer un commentaire