如何在尽可能少的代码中解决while循环和if语句问题[关闭]

问题描述 投票:-3回答:1

我试图允许我的列表检查用户是否拒绝该请求,如果是,则激活我的if块,允许我邀请其他访客。每次我输入no,而不是激活if块它继续打印,我哪里出错了?或者我错过了哪些元素?

guestllist = ["me","batman","joker","wonder woman","peter rabbit"]
normal = guestllist
guestllist.reverse()

while len(normal):
    # print("welome to the party "  + guestllist.pop())
    result = input("can you come " + guestllist.pop() + "?")
    if result == "no":
        print(result + " cannot make it")
        input("our new guest shall be ")
python loops
1个回答
-1
投票
guestllist = ["me","batman","joker","wonder woman","peter rabbit"]
guestllist.reverse()
while len(guestllist):
    result = input("can you come " + guestllist.pop() + "?")
    if result == "no":
        print(result + " cannot make it")
        input("our new guest shall be ")
© www.soinside.com 2019 - 2024. All rights reserved.