Copied a ChatGPT program on replit for snake, water , gun game but not getting the desired output? How to rectify? /u/FewNectarine623 Python Education

import random def determine_winner(player_choice,computer_choice): if player_choice == computer_choice: return "It's a tie!" if(player_choice =="snake" and computer_choice =="water") or (player_choice =="water" and computer_choice =="gun") or (player_choice =="gun" and computer_choice =="snake"): return "You win!" else: return "Computer wins!" def display_choices(): print("Choose one of the following:") print("1.Snake") print("2.Water") print("3.Gun") def snake_Water_gun_game(): print("Welcome to Snake Water Gun Game!") display_choices() player_choice = input("Enter your choice (snake/water/gun):").lower while player_choice not in ["snake","water","gun"]: print("Invalid choice! Please choose again.") display_choices() player_choice = input("Enter your choice (snake/water/gun):").lower() computer_choice = random.choice(["snake","water","gun"]) print(f"nPlayer chose:{player_choice}") print(f"Computer chose:{computer_choice}") result = determine_winner(player_choice,computer_choice) print(result) play_again = input("n Do you want to play again?(y/n):").lower if play_again =="y": snake_Water_gun_game() else: print("Thanks for playing! Goodbye.") snake_Water_gun_game() 

Link to o/p https://imgur.com/a/NJaECaV

snake showing invalid choice. on entering y yes I want to play again.. thanks ! goodbye How to rectify?

submitted by /u/FewNectarine623
[link] [comments]

​r/learnpython import random def determine_winner(player_choice,computer_choice): if player_choice == computer_choice: return “It’s a tie!” if(player_choice ==”snake” and computer_choice ==”water”) or (player_choice ==”water” and computer_choice ==”gun”) or (player_choice ==”gun” and computer_choice ==”snake”): return “You win!” else: return “Computer wins!” def display_choices(): print(“Choose one of the following:”) print(“1.Snake”) print(“2.Water”) print(“3.Gun”) def snake_Water_gun_game(): print(“Welcome to Snake Water Gun Game!”) display_choices() player_choice = input(“Enter your choice (snake/water/gun):”).lower while player_choice not in [“snake”,”water”,”gun”]: print(“Invalid choice! Please choose again.”) display_choices() player_choice = input(“Enter your choice (snake/water/gun):”).lower() computer_choice = random.choice([“snake”,”water”,”gun”]) print(f”nPlayer chose:{player_choice}”) print(f”Computer chose:{computer_choice}”) result = determine_winner(player_choice,computer_choice) print(result) play_again = input(“n Do you want to play again?(y/n):”).lower if play_again ==”y”: snake_Water_gun_game() else: print(“Thanks for playing! Goodbye.”) snake_Water_gun_game() Link to o/p https://imgur.com/a/NJaECaV snake showing invalid choice. on entering y yes I want to play again.. thanks ! goodbye How to rectify? submitted by /u/FewNectarine623 [link] [comments] 

import random def determine_winner(player_choice,computer_choice): if player_choice == computer_choice: return "It's a tie!" if(player_choice =="snake" and computer_choice =="water") or (player_choice =="water" and computer_choice =="gun") or (player_choice =="gun" and computer_choice =="snake"): return "You win!" else: return "Computer wins!" def display_choices(): print("Choose one of the following:") print("1.Snake") print("2.Water") print("3.Gun") def snake_Water_gun_game(): print("Welcome to Snake Water Gun Game!") display_choices() player_choice = input("Enter your choice (snake/water/gun):").lower while player_choice not in ["snake","water","gun"]: print("Invalid choice! Please choose again.") display_choices() player_choice = input("Enter your choice (snake/water/gun):").lower() computer_choice = random.choice(["snake","water","gun"]) print(f"nPlayer chose:{player_choice}") print(f"Computer chose:{computer_choice}") result = determine_winner(player_choice,computer_choice) print(result) play_again = input("n Do you want to play again?(y/n):").lower if play_again =="y": snake_Water_gun_game() else: print("Thanks for playing! Goodbye.") snake_Water_gun_game() 

Link to o/p https://imgur.com/a/NJaECaV

snake showing invalid choice. on entering y yes I want to play again.. thanks ! goodbye How to rectify?

submitted by /u/FewNectarine623
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *