dimanche 7 mars 2021

Python error: "TypeError: Object of type 'NoneType' has no len()"

How can I fix this error? I am attempting to eliminate the number of names the user chooses.

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()



Aucun commentaire:

Enregistrer un commentaire