python-循环时应为缩进块
这是我的代码,创建了一个石头剪刀游戏。 我没有别的话要说,除了 这里的系统说我需要更多的细节,因为有太多的代码,所以我随机键入。谢谢你python-循环时应为缩进块,python,while-loop,break,Python,While Loop,Break,这是我的代码,创建了一个石头剪刀游戏。 我没有别的话要说,除了 这里的系统说我需要更多的细节,因为有太多的代码,所以我随机键入。谢谢你 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
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
为什么会出现这个错误?休息时间到了。
我尝试了不同的方法,但都不管用。。
谢谢你的帮助 在while循环中包含“if input=='exit'”,然后在其中缩进“break”我看到的唯一错误是
break
语句没有缩进到最末端的if
下,但是整个if
语句也应该是while
循环的一部分;您应该始终发布收到的确切错误消息。