作者jimmycoco (JIMMY)
看板Python
標題[問題] 自學新手的一個問題
時間Sun Jan 22 22:36:19 2012
number = 23
running = True
while running:
guess = int(raw_input('Enter an integer : '))
if guess == number:
print 'Congratulations, you guessed it.'
running = False # this causes the while loop to stop
elif guess < number:
print 'No, it is higher than that.'
else:
print 'No, it is lower than that.'
else:
print 'The while loop is over'
print 'Done'
請問 在running = False # this causes the while loop to stop
這邊會讓迴圈停止 為什麼啊??
麻煩各位高手為小弟解惑 順便一問PYTHON 的學習手冊有二手或那裡租的到嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.45.87.106
→ uranusjr:while 後面的陳述為 False 時, 會跳出 while block 01/22 22:41
→ yudsx:設定成False之後,下次執行到迴圈判斷就會跳出迴圈 01/23 23:39
→ jimmycoco:了解了 謝謝 01/24 11:42