dimanche 16 mai 2021

python avoid printing duplicate [duplicate]

Hello I need my python program to avoid printing duplicate, let say I have a list

mylist = [1, 2, 3, 4, 5]

line = random.choice(mylist)

print(line) 

Here sometime the program will print in duplicate so I need to avoid that

I have tried random.sample but I didn't work




Aucun commentaire:

Enregistrer un commentaire