jeudi 25 janvier 2018

contructing an if statement with an or in python [duplicate]

This questions may have been asked before, I've looked and could not find what I needed.

I'm looking to do something rather simple: make an if statement that has multiple options:

if a == 1 or 2:
    do something
else:
    do something else

My formatting on the 'a == 1 or 2' is not correct. I've tried using:

if a == [1 or 2]
if a == np.logical_or(1, 2)

And neither of those work. I'm sure there's a way to do it, I'm having difficulty figuring out how. What would you suggest?

Aucun commentaire:

Enregistrer un commentaire