Python 而循环根本不工作

Python 而循环根本不工作,python,python-3.x,Python,Python 3.x,所以主要的问题是,我的程序在输入“Y”后不会继续,它只是在shell中停止,没有任何错误。 任何帮助都将不胜感激。提前感谢您的,而条件为false,因此您的程序结束 ready = input('Are you ready to start the quiz? [Y/N]: ') if ready == "N": quiz() else: questionsasked = [] qnum = random.randint(1,5) questionsaske

所以主要的问题是,我的程序在输入“Y”后不会继续,它只是在shell中停止,没有任何错误。
任何帮助都将不胜感激。提前感谢

您的
,而
条件为false,因此您的程序结束

ready = input('Are you ready to start the quiz? [Y/N]: ')

if ready == "N":

    quiz()

else:
    questionsasked = []
    qnum = random.randint(1,5)
    questionsasked.append((qnum))
    while (qnum)not in(questionsasked):

如果用户输入N,则调用quick()?这只是代码的一部分,“N”部分工作正常。(它重新启动整个程序)。但else部分根本不起作用,它和while loopwell有关,因为您的代码不完整,所以。。。。我们能提供什么帮助?您知道您只是将
qnum
添加到
questionsasked
中,然后您的循环在
qnum
不在
questionsasked
中时运行?
questionsasked = []
qnum = random.randint(1,5)
questionsasked.append((qnum))            # added qnum to questionsasked
while (qnum)not in(questionsasked):      # qnum is in questionsasked, so condition is false.
    ...