我该如何解决,x不在列表中

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

这是此子例程的代码

def elimination():
    global name
    global contestants
    global tempContestants
    global lipsync_songs
    global bottom_two
    bottom = tempContestants[0:len(tempContestants)-1]
    tempContestants.remove(bottom)
    bottom1 = tempContestants[0:len(tempContestants)-1]
    tempContestants.remove(bottom1)
    bottom_two = [bottom, bottom1]
    print(bottom_two[0], "and", bottom_two[1], "I'm sorry my dears but you are up for elimination")
    lipsync()
    eliminated = bottom_two[random.randint(0,len(bottom_two)-1)]
    bottom_two.remove(eliminated)
    safe = str(bottom_two)
    print("Ladies, I have made my decision")
    print(safe+", shantay you stay!")
    print(eliminated+", sashay away!")
    contestants.remove(eliminated)
    if eliminated == name:
        print("You have been eliminated!")
        quit()

这是错误消息

    tempContestants.remove(bottom)
ValueError: list.remove(x): x not in list

这是什么意思,我该如何解决?

python typeerror
2个回答
1
投票

0
投票
© www.soinside.com 2019 - 2024. All rights reserved.