Question: Correct this python coding for the Guessing Game (Rock, Paper, Scissors, Lizard, Spock), run it in python, post a screenshot of the code in python
Correct this python coding for the Guessing Game (Rock, Paper, Scissors, Lizard, Spock), run it in python, post a screenshot of the code in python and write the corrected codes on Chegg, plain straightforward and simple (using the appropriate python indentations).
import random def get_choice(): # This function gets the user's choice of move. choice = input("Enter your choice (Rock, Paper, Scissors, Lizard, Spock):") choice=choice.lower() if choice in ["rock", "paper", "scissors", "lizard", "spock"]: return choice else: print("Invalid choice. Try again. ") return get_choice() def get_computer_choice(): # This function gets the computer's choice of move. choices = ["rock", "paper", "scissors", "lizard", "spock"] return random.choice(choices) def get_winner(player_choice, computer_choice): # This function determines the winner of the game. if player_choice==computer_choice: return "tie" elif player_choice == "rock": if computer_choice == "scissors" or computer_choice == "lizard": return "player" else: return "computer" elif player_choice == "paper": if computer_choice == "rock" or computer_choice == "spock": return "player" else: return "computer" elif player_choice =="scissors": if computer_choice =="paper" or computer_choice =="lizard": return "player" else: return "computer" elif player_choice =="lizard": if computer_choice =="paper" or computer_choice =="spock": return "player" else: return "computer" elif player_choice =="spock": if computer_choice =="scissors" or computer_choice =="rock": return "player" else: return "computer" while True: player_choice = get_choice() computer_choice = get_computer_choice() winner = get_winner(player_choice, computer_choice) if winner == "tie": print("Tie!") elif winner == "player": print("You win!") elif winner == "computer": print("Computer wins!") play_again = input("Do you want to play again? (yes/no)") if play_again.lower() != "yes": break
This is what the program should do:
Ask the user for their choice (Rock, Paper, Scissors, Lizard, Spock); this can be done through a menu choice or in any other way.
The program will randomly choose one of the five possibilities.
The program will generate the winner and an appropriate statement based on the following:
Rock crushes Lizard
Rock destroys Scissors
Paper disproves Spock
Paper covers Rock
Scissors cuts Paper
Scissors decapitates Lizard
Lizard eats Paper
Lizard Poisons Spock
Spock smashes Scissors
Spock vaporizes Rock
The user will then be asked if they want to play again, and the process repeats until they choose to stop playing.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
