jeudi 8 juillet 2021

How do I remove a random choice from a list in Python3

Hello I'm coding a program that involves the need to choose a random item from a list, and I would like to remove the item that just got chosen from the list so it doesn't get rechosen could I get help? Here is my code so far:

    import random
import time
NameList = ["John", "Johnny", "Jonas", "Johan",
            "Jonathan", "Jack", "James", "Jacob", "Jake"]
for i in NameList:
    current_name = random.sample(NameList, 1)
    print(current_name)
    time.sleep(0.5)



Aucun commentaire:

Enregistrer un commentaire