0
Plzz help why this code is not working propely, its printing only first statement?
alien = 'green' or 'yellow' or 'red' if alien == 'green': print('earned 5') if alien == 'yellow': print('earned 10') if alien == 'red': print('earned 15') output: earned 5
3 Respuestas
+ 2
A variable (say, var) can’t be ‘x’ or ‘y’ or ‘z’ where it will return True if var is equal to one of ‘x’, ‘y’ or ‘z’.
You can have
var = (‘x’, ‘y’, ‘z’)
and say
if ‘x’ in var:
print(...)
if ‘y’ in var:
print(...)
if ‘z’ in var:
print(...)
+ 2
You have created this question twice. Would you mind deleting 1
https://www.sololearn.com/Discuss/1713249/?ref=app
0
you are right thanks for helpling.. its working fine..
alien1 = 'green,yellow,red'
if 'green' in alien1:
print(earned 5)
....
...