0
確定這裏是While循環替換Else語句?(Python)的
done = False
while not done:
quit = input ("Do you want to quit? ")
if quit == "y" :
done = True;
if not done:
attack = input ("Does your elf attack the dragon? ")
if attack == "y":
print ("Bad choice, you died.")
done = True;
,但是當我到達
Do you want to quit?
我進入
n
我得到
Traceback (most recent call last):
File "C:\Users\your pc\Desktop\JQuery\dragon.py", line 4, in <module>
quit = input ("Do you want to quit? ")
File "<string>", line 1, in <module>
NameError: name 'n' is not defined
根據此http://www.youtube.com/watch?feature=player_embedded&v=2Z2pH0Ls9Ew#! 它應該工作
嘗試的raw_input'()'代替。 – 2013-05-02 16:27:06