瑜阳 发表于 2017-4-27 21:42:04

新手小白求大神看看我的这个作业的问题谢谢啦

print("~~~~~~~~~~game~~~~~~~~~")
temp = input("猜一猜我心里的数字:")
guess = int(temp)
while gusee!=8:
    temp = input("诶呀猜错了,请从新输入吧:")
    guess = int(temp)
    if guess == 8:
      print("你猜对了")
    else:
      if guess > 8:
         print("大了,大了")
      else:
         print("小了小了")
print("game over")               

太阳花田 发表于 2017-4-27 21:47:21

while里面改成guess = int(input())   你这样guess永远是 原始值无限循环了

shnw 发表于 2017-4-27 21:50:34

没看出问题来。。。。。。。。{:5_100:}

shnw 发表于 2017-4-27 21:55:21

试了试没问题啊

太阳花田 发表于 2017-4-27 22:02:23

本帖最后由 太阳花田 于 2017-4-27 22:11 编辑

我看错了 sorryNameError: name 'gusee' is not defined你的while那里写成了gusee原为guess
你把这句英文一翻译就知道了要学会看异常调debug

瑜阳 发表于 2017-4-27 22:08:04

Python 3.5.1 (v3.5.1:37a07cee5969, Dec6 2015, 01:38:48) on win32
Type "copyright", "credits" or "license()" for more information.
>>>
=========================== RESTART: C:\学习\2.0.py ===========================
~~~~~~~~~~game~~~~~~~~~
猜一猜我心里的数字:8
Traceback (most recent call last):
File "C:\学习\2.0.py", line 4, in <module>
    while gusee!=8:
NameError: name 'gusee' is not defined
>>>
用的时候就是显示的这个

太阳花田 发表于 2017-4-27 22:09:55

瑜阳 发表于 2017-4-27 22:08
Python 3.5.1 (v3.5.1:37a07cee5969, Dec6 2015, 01:38:48) on win32
Type ...

NameError: name 'gusee' is not defined 名字异常:gusee没有定义   看上面楼

瑜阳 发表于 2017-4-27 22:11:01

{:10_266:}谢谢亲
页: [1]
查看完整版本: 新手小白求大神看看我的这个作业的问题谢谢啦