作业帮 > 综合 > 作业

python 就是输入'done'的时候,能跳出while loop,不然就继续在while里面.def userCho

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/07/07 13:38:35
python
就是输入'done'的时候,能跳出while loop,不然就继续在while里面.
def userChoice():
global n
n = "done"
while n = "done":
n = input("Please enter your choice:")
userChoice()
错在哪了?如果我改成while n=="done",然后输入done,它就一直都在while里,但是我想要输入done的时候,它能跳出while,我以为改成 = 就可以了,可是还是不行.
'''
Created on 2011-2-20
@author:louis
'''
def userChoice():
global n
n = ""
while n != "done":
n = raw_input("Please enter your choice:")
print n
userChoice()