# Functions go here 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)""" error = "Oops - please enter an integer more than zero" while True: response = input(question).lower() # check for exit code if response == exit_code: return response try: # Change the response to an integer and check that it's more than zero response = num_type(response) if response > 0: return response else: print(error) except ValueError: print(error) # Main Routine goes here # loop for testing purposes... while True: print() my_float = num_check("You can enter a decimal or whole number more than 0: ", float) print(f"Thanks. You chose {my_float}") print() my_int = num_check("You can only enter a whole number more than 0: ", int, "") if my_int == "": print("You have chosen infinite mode") else: print(f"Thanks. You chose {my_int}")