I am trying to code a rock, paper, scissors game but am struggling with the final step. When I run the module, it does everything up to showing what the computer chose. However, it does not finish the code and display the result of the game. I am very new to python so any help is appreciated. Here is the code:
from random import randint
print ("Welcome to Rock, Paper, Scissors")
print ("Try to beat this program in a simple game of Rock, Paper, Scissors.")
player = input('Rock, paper, or scissors ')
if player == 'rock':
player == 'r'
elif player == 'paper':
player == 'p'
elif player == 'scissors':
player == 's'
chosen = randint(1,3)
if chosen == 1 :
computer = "rock"
print ("computer chose rock")
elif chosen == 2 :
computer = "paper"
print ("computer chose paper")
else:
computer = "scissors"
print ("computer chose scissors")
def func(player, computer):
if player == 's' and computer == "rock":
return ("You lost!")
elif player == 's' and computer == "paper":
return "You win!"
elif player == 's' and computer == "scissors":
return "You tied!"
elif player == 'r' and computer == "rock":
return "You tied!"
elif player == 'r' and computer == "paper":
return "You lost!"
elif player == 'r' and computer == "scissors":
return "You win!"
elif player == 'p' and computer == "rock":
return "You win!"
elif player == 'p' and computer == "paper":
return "You tied!"
elif player == 'p' and computer == "scissors":
return "You lost!"
