这个代码为什么错啦(小甲鱼Python新版第6集)求回答
"""用Python设计第一个游戏"""
counts=3
while counts>0:
temp=input("请在1-10中猜一个数字:")
guess=int(temp)
if guess==8:
print("你真牛逼,猜对了!")
else:
if guess<8:
print("太小啦")
else:
print("太大了")
counts=coumts-1
print("游戏结束!") 大马强 发表于 2021-8-20 17:12
1、if的缩进
2.单词写错了
在吗
看一下我前面的回复吧{:10_266:} {:10_269:}{:10_257:}{:10_254:}{:10_266:}
1、if的缩进 if guess<8:
2.单词写错了 counts=coumts-1
counts = 3
while counts > 0:
temp = input("请在1-10中猜一个数字:")
guess = int(temp)
if guess == 8:
print("你真牛逼,猜对了!")
else:
if guess < 8:
print("太小啦")
else:
print("太大了")
counts=counts-1
print("游戏结束!") counts=coumts-1
打错字了吗? dqcgp 发表于 2021-8-20 17:14
counts=coumts-1
打错字了吗?
呃呃呃
本帖最后由 酸橙橙2333 于 2021-8-20 17:23 编辑
等一下为什么它报错了 invalid syntax
Python 3.9.6 大马强 发表于 2021-8-20 17:12
1、if的缩进
2.单词写错了
等一下为什么它报错了 invalid syntax
Python 3.9.6
酸橙橙2333 发表于 2021-8-20 17:25
等一下为什么它报错了 invalid syntax
Python 3.9.6
我这正常运行
"""用Python设计第一个游戏"""
counts = 3
while counts > 0:
temp = input("请在1-10中猜一个数字:")
guess = int(temp)
if guess == 8:
print("你真牛逼,猜对了!")
else:
if guess < 8:
print("太小啦")
else:
print("太大了")
counts=counts-1
print("游戏结束!") https://static01.imgkr.com/temp/1172624a34b649b1b317766412444562.jpg 大马强 发表于 2021-8-20 17:41
我这正常运行
Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> """用Python设计第一个游戏"""
counts = 3
while counts > 0:
temp = input("请在1-10中猜一个数字:")
guess = int(temp)
if guess == 8:
print("你真牛逼,猜对了!")
else:
if guess < 8:
print("太小啦")
else:
print("太大了")
counts=counts-1
大马强 发表于 2021-8-20 17:42
蛤 C:\Users\air\Desktop\学习资料\1\Scripts\python.exe "C:/Users/air/Desktop/学习资料/真 1.py"
File "C:\Users\air\Desktop\学习资料\真 1.py", line 1
Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) on win32
^
SyntaxError: invalid syntax
进程已结束,退出代码为 1
大马强 发表于 2021-8-20 17:41
我这正常运行
请在1-10中猜一个数字:5
太小啦
请在1-10中猜一个数字:9
太大了
请在1-10中猜一个数字:8
你真牛逼,猜对了!
游戏结束!
进程已结束,退出代码为 0
成功啦
酸橙橙2333 发表于 2021-8-20 18:01
请在1-10中猜一个数字:5
太小啦
请在1-10中猜一个数字:9
正常就好{:10_297:}
页:
[1]