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?")
语句并进入无限循环。