Reputation: 23
I'm trying to have the code reject someone If they're under 13 and over 20 then, accept when they're over 13. It was working before I added the over 20 part but now I enter a age under 13 it plays both under 13 and else. Should I have worded it better?
if age<13:
print("sorry young warrior but you shall not pass.")
if age>20:
print("Why are you here you old geezer.")
else:
print("Welcome to the clan!")
Upvotes: 1
Views: 59
Reputation: 366
You can use interval comparison and have:
if 13 < age < 20:
print("No no no")
else:
print("Welcome to the clan!")
or if you need explicit print statements for these cases, just handle the rest in elif
:
if age<13:
print("sorry young warrior but you shall not pass.")
elif age>20:
print("Why are you here you old geezer.")
else:
print("Welcome to the clan!")
Upvotes: 1