# Check that users have entered a valid # option based on a list def string_checker(question, valid_ans=('yes', 'no')): error = f"please enter a valid option from following list: {valid_ans}" while True: user_response = input(question).lower() for item in valid_ans: if item == user_response: return item elif user_response == item[0]: return item # print error if user does not enter something that valid print(error) print() # checks for an integer more than 0 (allows ) def int_check(to_check): while True: error = "Please enter an integer that is 1 or more." #check for infinity mode if to_check == "": return "infinite" try: response = int(to_check) # checks that the number is more than / equal to 13 if response < 1: # print(error) return "invalid" else: return response except ValueError: # print(error) return "invalid" # Automated testing is below in the form (test_case, expected_value) to_test = [ ('xlii', 'invalid'), ('0.5', 'invalid'), ('0', 'invalid'), (1, 1), (2, 2), ('', 'infinite'), ] # run tests! for item in to_test: # retrieve test case and expected value case = item[0] expected = item[1] # get actual value (ie: test ticket function) actual = int_check(case) # compare actual and expected and output pass / fail if actual == expected: print(f" ✅✅✅Passed! Case: {case}, expected: {expected}, received: {actual} ✅✅✅") else: print(f"❌❌❌ Failed! Case: {case}, expected: {expected}, received: {actual} ❌❌❌")