亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

新手之路:代碼定義錯誤

新手之路:代碼定義錯誤

阿晨1998 2018-07-16 11:20:21
代碼如下: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 回答

?
SMILET

TA貢獻1796條經驗 獲得超4個贊

gurss = 0

guess

拼寫錯誤。。。。


查看完整回答
反對 回復 2018-07-17
?
慕娘9325324

TA貢獻1783條經驗 獲得超4個贊

第三行 guess

查看完整回答
反對 回復 2018-07-17
  • 2 回答
  • 0 關注
  • 324 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號