MAX_CHIPS = 21 name1_points = 0 name2_points = 0 while True: name1 = input("What is your name P1? ") if name1.isalpha(): print("Hello", name1) break else: print("That is not your name") while True: name2 = input("What is your name P2? ") if name2.isalpha(): print("Hello", name2) break else: print("That ain't your name") while True: try: num_rounds = int(input("How many rounds do you want to play (between 1-5): ")) if 1 <= num_rounds <= 5: break else: print("Choose between 1-5") except ValueError: print("Just Choose a number between 1-5") for _ in range(num_rounds): chips_left = MAX_CHIPS while chips_left > 0: print(chips_left, "chips left.") # Player 1's turn while True: chips_taken = int(input(f"{name1}, how many chips would you like to take (1-3)? ")) if 1 <= chips_taken <= 3 and chips_taken <= chips_left: break else: print("Invalid input. Please choose between 1-3 and no more than the remaining chips.") chips_left -= chips_taken print(f"{name1} took {chips_taken} chips. {chips_left} chips left.") if chips_left == 0: name1_points += 1 print(f"One point for {name1}!") break # Player 2's turn while True: chips_taken = int(input(f"{name2}, how many chips would you like to take (1-3)? ")) if 1 <= chips_taken <= 3 and chips_taken <= chips_left: break else: print("Invalid input. Please choose between 1-3 and no more than the remaining chips.") chips_left -= chips_taken print(f"{name2} took {chips_taken} chips. {chips_left} chips left.") if chips_left == 0: name2_points += 1 print(f"One point for {name2}!") break print("Game Finished!") # Determine the winner if name1_points > name2_points: print(f"{name1} won with {name1_points} points!") elif name2_points > name1_points: print(f"{name2} won with {name2_points} points!") else: print("It's a draw!")