如何修复此错误?我试图消除用户选择的名称数量
names = []
def eliminate():
votes = int(input("How many people would you like voted off? "))
popped = random.shuffle(names)
for i in range(votes):
names.pop(len(popped))
print("The remaining players are" + names)
for i in range(0,6):
name = input("Give me a name: ")
names.append(name)
eliminate()
random.shuffle(names)
不返回任何内容或返回None
。但是,您的“姓名”列表正在被洗牌。 您可以得到以下结果:^{} 返回
None
,而不是实际已被洗牌的洗牌列表。由于要弹出列表中的最后一项,因此不需要为pop()
提供索引:相关问题 更多 >
编程相关推荐