def num_check(question, num_type , exit_code=None): """checks user enter an integer / foat that is more than zero""" if num_type == "interger": error = "oops - please enter an interger more than zero " change_to = int else: error = "opps - please enter an number more than zero" change_to = float while True: response = input(question).lower() if response == exit_code: return response try: # changing the responce to an integer and check that it is more than 0 response = change_to (response) if response > 0: return response else: print (error) except ValueError: print (error) #main loop goses here while True: print() my_float = num_check("please enter a number more than zero:", 'float') print(f"thanks. you chose {my_float}") print() my_int = num_check("please enter an ineger more than zero", "interger", "") if my_int == "": print("you have chosen infinate mode") else: print(f"thanks. you chose {my_int}")