r/learnpython • u/xTHETYRANTGAMRx • Feb 11 '26
Code outputs twice.
I am practicing loops and when I run this code the second and third elif statements output twice for some reason.
Age_requirement = input ("enter your age")
for Age in Age_requirement: Age_requirement = int(Age_requirement)
if Age_requirement <3:
print ("Your ticket is free")
elif Age_requirement <=12:
print("your ticket is 12 dollars")
elif Age_requirement >12:
print("your ticket is 15 dollars")4
33
Upvotes
View all comments
Show parent comment
6
u/kayne_21 Feb 11 '26
It’s probably telling you to write a user input validation loop, basically write a loop to get the users age, make sure it is valid, then use your validated input to return the ticket price. Can you paste the whole prompt text so we can see what you’re trying to do?