我正在尝试为我的一个类创建一个猜谜游戏,但是 “无效语法”错误不断出现。以下代码的任何解决方案 非常感谢!你知道吗
import random
goal = random.randint(1,100)
guess = 0
print("\nThe object of this game is to\nguess a number"
"between 1 and 100")
while guess != goal:
guess = int(input("Please guess the number: ")
if guess > goal:
print("\nToo high, try again.")
elif guess < goal:
print("\nToo low, try again.")
else:
print("Well done!")
print("\nSee you later")
这行缺少括号:
应该是:
误差是由于压痕不均匀造成的。您不需要在猜测输入之后缩进if。 还有guess输入中缺少的括号
此行缺少右括号:
应该是
另外,缩进是不一致的,因为您在
while
语句后使用了4个空格,但在后面的if
语句中使用了2个空格以下是我的作品:
相关问题 更多 >
编程相关推荐