command= " "
while True:
command = int(input("how old are you? "))
if command <= 12:
print("you're ticket is free.")
elif command <= 15:
print("you're ticket is $20.")
elif command > 15:
print("you're ticket is $50.")
elif command == "exit":
break
As I write exit
it gives a ValueError
,
ValueError: invalid literal for int() with base 10:'exit'
You should check if the command is exit before trying to convert the command to int:
while True:
command = input("how old are you? ")
if command == "exit":
break
command = int(command)
if command <= 12:
print("you're ticket is free.")
elif command <= 15:
print("you're ticket is $20.")
elif command > 15:
print("you're ticket is $50.")