python - python - 期望一个缩进块while循环
问题描述
所以这是我的代码,创建一个石头剪刀布游戏。我没有别的要说,但这里的系统说我需要更多细节,因为代码太多所以我随机输入。不过谢谢你。
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”
推荐阅读
- r - Wu Hausman 检验检验内生性
- function - LLVM 中多个程序集文件的内联函数
- java - java代码,如果我们希望只有在firebase中经过身份验证的人可以写入,而其他人可以读取未经身份验证的人
- mysql - 我想在 23:59:59 将访问者人数插入 mysql 数据库,但我的数据库有意外数据
- android - 单击按钮时,Countdowntimer 取消使应用程序崩溃
- c# - 仅在单击字段后启用必需的属性验证
- katalon-studio - 无法使用带有 Ubuntu 20.04 的 Katalon Studio 进行录制
- node.js - if 语句未在 for 循环内执行
- django - 通过 DRF 中的按位运算符组合的每个权限的唯一消息
- flutter - 在其他页面中打开抽屉