# functions def float_check(question): """checks users enter a float""" error = "Oops - please enter a number more than zero." while True: response = input(question).lower() # check for exit code if response == "xxx": return response try: # change response to an integer and check it's more than 0 response = float(response) if response > 0: return response else: print(error) except ValueError: print(error) # main routine # testing loop while True: my_float = float_check("Please enter a number: ")