def num_check(question, num_type, exit_code=None): """Checks users enter an integer / float that is more than zero (or the optional exit code)""" if num_type == "integer": error = "Oops - please enter an integer more than zero." change_to = int else: error = "Oops - please enter a number more than zero." change_to = float while True: response = input(question).lower() # check for the exit code if response == "xxx": return response try: # Change the response to an integer amd check that it's more than zero response = change_to(response) if response > 0: return response else: print(error) except ValueError: print(error) 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")