mercredi 1 juin 2022

Why the entire list get printed instead of single? [closed]

#when trying to print y. It is giving the entire list instead of the name of a single person.

import random
names_string = input("Give me everybody's names, separated by a comma. ")
names = names_string.split(", ")

print(names)
z=(len(names))
k=random.randint(0,z-1)
y=names[k]
print(y)



Aucun commentaire:

Enregistrer un commentaire