【发布时间】:2018-11-06 06:36:27
【问题描述】:
这是我的代码,创建一个石头剪刀布游戏。 除了 这里的系统说我需要更多细节,因为代码太多所以我随机输入。不过还是谢谢你。
options=["rock","paper","scissors"]
your_wins=0
my_wins=0
while input!="exit":
turn = input("Please choose rock,paper or scissors:")
print("you chose:" + turn)
import random
my_choice = random.choice(options)
print("I chose:" + my_choice)
if my_choice=="rock" and turn=="rock":
print("its a tie!")
if my_choice=="paper" and turn=="rock":
print("you lose!")
if my_choice=="scissors" and turn=="rock":
print("you win!")
if my_choice=="paper" and turn=="paper":
print("its a tie!")
if my_choice=="scissors" and turn=="paper":
print("you lose!")
if my_choice=="rock" and turn=="paper":
print("you win!")
if my_choice=="paper" and turn=="scissors":
print("you win!")
if my_choice=="scissors" and turn=="scissors":
print("its a tie!")
if my_choice=="rock" and turn=="scissors":
print("you lose!")
if "you lose":
my_wins+=1
else:
your_wins+=1
if input=="exit":
break
为什么会出现这个错误?它在休息。 我尝试了不同的东西,但它就是行不通.. 谢谢你的帮助!!
【问题讨论】:
-
我看到的唯一错误是
break语句最后没有在if下缩进,但是整个if语句也应该旨在使其成为@987654325 的一部分@循环。 -
无论您遇到什么错误,都应包括发生错误的行;您应该始终发布您收到的准确错误消息。
标签: python while-loop break