gpt4 book ai didi

python - 我正在尝试用python制作剪刀石头布游戏,但出现缩进不匹配任何外部缩进杠杆错误的情况

转载 作者:行者123 更新时间:2023-12-03 08:39:52 25 4
gpt4 key购买 nike

这是代码。错误在input("Do you want to continue?")行上。

import random

def play():
gameOver = False
while not gameOver:
imput = input("rock, paper, or scissors?")
j = 0
if (imput == "rock"):
j = 1
elif(imput == "paper"):
j = 2
else:
j = 3

robot = random.randint(1,3)

if j == robot:
print("you got the same thing")
elif j == 1:
if robot == 2:
print("Rock vs Paper, you lose")
else:
print("Rock vs Scissors, you win!")
elif j == 2:
if robot == 1:
print("paper vs rock, you win!")
else:
print("paper vs scissors, you lose")

else:
if robot == 1:
print("Scissors vs Rock, you lose")
else:
print("Scissors vs paper, you win!")

decision = input("Do you want to continue?")
if decision == "yes":
gameOver == True

play()

最佳答案

运行您发布的代码时,我没有解析错误。我的猜测是制表符与空格。将编辑器的设置更改为在按Tab键时始终使用4个空格,并查找并替换所有现有的制表符以替换为4个空格。

关于python - 我正在尝试用python制作剪刀石头布游戏,但出现缩进不匹配任何外部缩进杠杆错误的情况,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62647952/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com