虽然循环根本不起作用

时间:2015-12-28 19:25:23

标签: python python-3.x

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):

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

1 个答案:

答案 0 :(得分:3)

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

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.
    ...