lundi 29 novembre 2021

How do I create a list of random strings value without duplicates?

How to generate random string of my list without duplication in python? i tried using random.sample but it keeps sending me duplicates sometimes.

import random 


column_arr = ['id', 'name', 'location', 'duration'
, 'id', 'name', 'quantity', 'unit'
, 'id', 'description', 'unit', 'quantity', 'unit_cost']


arr = []
for i in range(3):
      arr.append(random.choice(column_arr))
print(arr)



Aucun commentaire:

Enregistrer un commentaire