# Check that users have entered a valid # option based list from stringcheckerRPS2 import want_instructions def string_checker(question, valid_ans=('yes', 'no')): error = f"Please enter a valid option from the following list: {valid_ans}" while True: # Get user response and make sure it's lowercase user_response = input(question).lower() for item in valid_ans: # check if the user response is a word in the list if item == user_response: return item # check if the user response is the same as # the first letter of an item in the list elif user_response == item[0]: return item #print error if the user does mot enter something that is valid print(error) print() # Main Routine starts here # Initialise game variables mode = "regular" rounds_played = 0 rps_list = ["rock", "paper", "scissors", "xxx "] print("πŸͺ¨πŸ“ƒβœ‚️ Rock / Paper / Scissors πŸͺ¨πŸ“ƒβœ‚️") print() # Instructions # functions go here def yes_no(question): """Checks user response to question is yes / no (y/n), returns "yes" or "no""" while True: response = input(question).lower() #check the user says yes / no / y / n if response == "yes" or response == "y": return "yes" elif response == "no" or response == "n": return "no" else: print("please respond with yes or no") def instructions(): """Prints instructions""" print(""" *** Instructions *** Beat me in Rock, Paper, Scissors to win! """) # ask the user if they want instructions (check they say yes / no) want_instructions = yes_no("Do you want to see the instructions? ") # Display the instructions if the user wants to see them if want_instructions -- "yes": instructions() print() print("program continues") # Ask User for number of rounds / infinite mode num_rounds = int_check("How many rounds would you like? Push for infinite mode: ") if num_rounds == "infinite": mode = "infinite" num_rounds = 5 # Game loop starts here while rounds_played < num_rounds: # Rounds headings if mode == "infinite": rounds_heading = f"\n Round {rounds_played + 1} (infinite Mode)" else: rounds_heading = f"\nπŸ’ΏπŸ’ΏπŸ’Ώ Round {rounds_played} of {num_rounds}πŸ’ΏπŸ’ΏπŸ’Ώ" print(rounds_heading) print() user_choice = string_checker("Choose: ", rps_list) print("you chose: ", user_choice) # Allows the user to end infinite mode when they want to if user_choice == "xxx": break rounds_played += 1 # if users are in infinite mode, increase number of rounds if mode == "infinite": num_rounds += 1 # Game loop ends here #Game History / Statistics area