我需要在此岩纸仪代码中做什么?
我陷入了此代码的最后位。我不知道下一步该怎么办。
我需要游戏从列出的选项中选择一个随机选项,以便他们可以与用户选择。
有人可以将我指向正确的方向吗?
# Rock paper Scissors Game
# Question 1
print("Want to play Rock Paper Scissors??")
question1=input("Y/N: ").lower()
if question1=='y':
print('Perfect but first')
elif question1== 'n':
print('Sorry but your here already')
else: print('error')
# Question 2
print('Do you know how to play??')
question2=input("Y/N: ").lower()
if question2=='y':
print('Ok lets get started!')
elif question2=='n':
print('Pick 1 of the 3 options to battle my option')
print('Rock beats scissors')
print("Paper beats rock")
print('Scissors beats paper')
else:
print('error')
# Display game options
options = ['Rock', 'Paper', "Scissors"]
def random_choose(options):
pick = input('Take your pick: ')
return pick, random.choose(options)
I'm stuck on the last bit of this code. I don't know what to do next.
I need the game to pick a random option out of the listed options so they can battle the users pick.
Could someone point me in the right direction?
# Rock paper Scissors Game
# Question 1
print("Want to play Rock Paper Scissors??")
question1=input("Y/N: ").lower()
if question1=='y':
print('Perfect but first')
elif question1== 'n':
print('Sorry but your here already')
else: print('error')
# Question 2
print('Do you know how to play??')
question2=input("Y/N: ").lower()
if question2=='y':
print('Ok lets get started!')
elif question2=='n':
print('Pick 1 of the 3 options to battle my option')
print('Rock beats scissors')
print("Paper beats rock")
print('Scissors beats paper')
else:
print('error')
# Display game options
options = ['Rock', 'Paper', "Scissors"]
def random_choose(options):
pick = input('Take your pick: ')
return pick, random.choose(options)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,对于这个问题,循环将有助于游戏更具动态性,使玩家能够直到玩家退出游戏为止。我还将您的代码的部分集成到了该修订后的部分中。希望这会有所帮助
Well, for this question a while loop would help the game be more dynamic, allowing the player to until the player opt-out of the game. I also integrated parts of your code into this revised one. Hope this helps