def num_check(question, num_type="float", exit_code=None): """Checks that response is a float / integer more than zero""" if num_type == "float": error = "Please enter a number more than 0." else: error = "Please enter an integer more than 0." while True: response = input(question) # check for exit code and return it if entered if response == exit_code: return response # check datatype is correct and that number # is more than zero try: if num_type == "float": response = float(response) else: response = int(response) if response > 0: return response else: print(error) except ValueError: print(error) def not_blank(question): while True: response = input(question) if response != "": return response print("Sorry, this can't be blank. Please try again. \n") # Main routine goes here # loop for testing purposes while True: employee_name = not_blank("Employee Title") employee_amount = num_check("Amount of employees: ", "integer") print(f"You are employing {employee_amount} {employee_name}s") print()