For a case without using a
In your initial case that could have been done by using the
ie:
break
one would generally use only one main if
block (to prevent potential unintended fall-trough into the other if's).In your initial case that could have been done by using the
else
option of the if age == 'quit':
condition.ie:
#... active = True while active: age = input(prompt) if age == 'quit': active = False else: ## do stuff if age was not equal to 'quit'. age = int(age) if age < 3: print("\nYour ticket is free!") elif age < 12: print("\nYour ticket is 10$!") else: print("\nYour ticket is 15$!")