为了账号安全,请及时绑定邮箱和手机立即绑定

初学者摇滚,纸艺,剪刀游戏Python语法

初学者摇滚,纸艺,剪刀游戏Python语法

一只斗牛犬 2021-04-02 04:24:19
我创建了一个Rock Paper Scissors游戏。它询问您是否要玩,接受您的输入,将其与计算机的随机输入进行比较,为您提供结果,然后询问您是否要再次玩。我不知道为什么它不起作用。请让我知道如何解决它。谢谢你import randomimport sys#playdef play():  print('want to play?')if input()=='yes':  print("Pick R/P/S")  user = input()# RPSdef RPS():  x = random.choice( ['Rock', 'Paper', 'scissors'] )print(x)if x == 'Rock' and user == 'R':  print('Tie')elif x == 'Rock' and user == 'P':  print('You beat Comp')elif x == 'Rock' and user == 'S':  print('Beat you')#--------if x == 'Paper' and user == 'R':  print('Lost to comp')elif x == 'Paper' and user == 'P':  print('tie')elif x == 'Paper' and user == 'S':  print('you beat comp')#---------if x == 'scissors' and user == 'R':  print('Beat comp')elif x == 'scissors' and user == 'P':  print('lost comp')elif x == 'scissors' and user == 'S':  print('tie')#Play againdef playagain():  print('Want to play again')  play=input()if play=='yes':    RPS()else:    print("Thanks for playing")play()RPS()playagain()
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 149 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号