Python - 虽然语句在false语句时不生成

时间:2015-11-23 23:15:10

标签: python python-3.x while-loop

things = ["shorts", "pen", "pencil"]
userthings = input("what do you want to find?")
userthings = userthings.lower()
bagged = False
for i in things:
    if i == userthings:
        bagged = True

if bagged == True:
    print ("I has thing")
else:
    print ("I dont has thing")        

morestuff = input("Do you want to add anything else?")
morestuff = morestuff.lower()

while (morestuff == "yes" or "y"):
    stuff = input("What do you want to add?")
    str(stuff)
    things.append(stuff)
    print ("I have the following things:", things)
    morestuff = input("Do you want to add anything else?")
else:
    print ("Lol bye")

我的问题是while语句代码,当我在morestuff中输入“no”,或者"yes""y"以外的任何内容时,它不会打印"Lol bye"但是继续stuff = input("What do you want to add?")语句并进入无限循环。

0 个答案:

没有答案