求助
counts = 1while counts <2:
temp = input("猜一猜")
guess = int(temp)
if guess == 8:
print("ok")
break
else:
if guess <8:
print("小啦")
else:
print("大啦")
print("game over")
SyntaxError: invalid syntax
不知道哪里错了
看起来您的代码不完整。您是要使用`while`循环,但没有给出循环的完整条件或者循环体的内容。以下是一个使用`while`循环的基本示例:
counts = 1
while counts <= 5:# 这个条件可以根据需要改变
print("Count is:", counts)
counts += 1# 这行代码是为了更新`counts`的值,否则会出现无限循环
这个代码会从1打印到5。如果您有特定的需求或者条件,请补充信息,我可以提供更详细的帮助。
以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。 你的代码中存在一个缩进错误
counts = 1
while counts < 2:
temp = input("猜一猜")
guess = int(temp)
if guess == 8:
print("ok")
break
else:
if guess < 8:
print("小啦")
else:
print("大啦")
print("game over")
页:
[1]