,
, :
if a == 7:
pass
if a == 8:
pass
if a == 9:
...
else:
...
- if, , -
if a == 9:
therefore, if a is 7 or 8, the program prints yes. For future use of an if-else statement like this, be sure to use elif:
if a == 7:
seven()
elif a == 8:
eight()
elif a == 9:
nine()
else:
print "yes"
or use only one if statement if they require the same action:
if a == 7 or a == 8 or a == 9:
seven_eight_or_nine()
else:
print "yes"
source
share