这是我的第一天对编码和开始对岩石剪刀布游戏,我得到这个错误我怎么能修复这个
输入:
import random
def get_choices():
player_choice = (input('Enter a choice (Rock , Paper , Scissors)'))
c_choices = ['Rock', 'Paper', 'Scissors']
computer_choice = random.choice(c_choices)
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 "its 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 "SCISSOR CUTS PAPER!, YOU LOSE!"
elif player == 'scissors':
if computer == 'paper':
return "SCISSORS CUTS PAPER!, YOU WIN!"
else:
return "ROCK SMASHES SCISSORS!, YOU LOSE!"
choices = get_choices()
result = check_win(choices['player'], choices['computer'])
print(result)
1条答案
按热度按时间pxiryf3j1#
c_choices
中的字符串大写。在
def check_win()
中,你将它们与小写字符串进行比较。use:
而不是: