Created
July 28, 2022 20:56
-
-
Save beaucarnes/df77cda68afaca0aa1e12cc98b7dc0a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def get_choices(): | |
player_choice = input("Enter a choice (rock, paper, scissors): ") | |
options = ["rock", "paper", "scissors"] | |
computer_choice = random.choice(options) | |
choices = {"player": player_choice, "computer": computer_choice} | |
return choices | |
def check_win(player, computer): | |
print(f"You chose {player}, computer chose {computer}") | |
if player == computer: | |
return("It's a tie!") | |
elif player == "rock": | |
if computer == "scissors": | |
return("Rock smashes scissors! You win!") | |
else: | |
return("Paper covers rock! You lose.") | |
elif player == "paper": | |
if computer == "rock": | |
return("Paper covers rock! You win!") | |
else: | |
return("Scissors cuts paper! You lose.") | |
elif player == "scissors": | |
if computer == "paper": | |
return("Scissors cuts paper! You win!") | |
else: | |
return("Rock smashes scissors! You lose.") | |
for x in range(3): | |
print("Round " + str(x+1)) | |
choices = get_choices() | |
result = check_win(choices["player"], choices["computer"]) | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
but caN i USER THAT CODE FOR CREATED NEW GAME?