代码如下:import randomsecret = random.randint(1,99)gurss = 0tries = 0print "AHOY! I'm the Dread Pirate Roberts, and I have a secret!"print "It is a number from 1 to 99. I'll give you 6 tries."while guess != secret and tries < 6: guess = input ("What's yer guess?") if guess < secret: print "Two low,ye scurvy dog!" elif guess > secret: print "Two high,landubber!" tries = tries + 1if guess == secret: print "Avast! Ye got it! Found my secret, ye did!"else: print "No more guesses! Better luck next time,matey!" print "The secret number was", secret运行错误提示:Traceback (most recent call last): File "C:/Users/whisk/Desktop/编程学习/list.1-2.py", line 7, in <module> while guess != secret and tries < 6:NameError: name 'guess' is not defined是根据书籍《父与子的编程之旅》学习的,刚开始,对照了书上和自己写的代码,并没有拼写错误,希望有大神点一下,谢谢。
- 2 回答
- 0 关注
- 380 浏览
添加回答
举报
0/150
提交
取消
