# Functions go here def not_blank(question): """Checks that a user response is not blank""" while True: response = input(question) if response != "": return response print("Sorry this can't be blank. Please try again. \n") def int_check(question): """Checks users enter an integer that is more than zero (or the 'xxx' exit code)""" error = "Oops - please enter an integer" while True: try: # Return the response if it's an integer response = int(input(question)) return response except ValueError: print(error) # Main routine goes here # loop for testing purposes... while True: print() # Ask user for their name name = not_blank("Name: ") # Ask for their age and check it's between 12 and 120 age = int_check("Age: ") # Output error message / success message if age < 12: print(f"{name} is too young") continue elif age > 120: print(f"{name} is too old") continue else: print(f"{name} bought a ticket")