mercredi 28 janvier 2015

python 3 using multiple or and’s in an if statement

The code that follows always returns 'orange' I've found other ways to do what I want but I do not understand why this does not work.



color1 = input('select first color')
color2 = input('select second color')
if 'color1' == 'red' or 'yellow' and 'color2' == 'red' or 'yellow':
print('orange')
else:
print('something else')

Aucun commentaire:

Enregistrer un commentaire