lundi 27 mars 2017

Assigning random tuples to a dictionary

Please I need help with this, Thank you.

for i in conflictList:
    d[i] = random.sample(set(domainList),2)

This assigns only a single tuple to the key But i want to assign more than a single tuple, tried this but didnt work

for i in conflictList:
    while len(d[i]) < tup:
        d[i] = random.sample(set(domainList),2)

'tup' represents the number of tuples the user wants do if the user wants 3 tuples, it gives something like this:
(x1,x2): (0,1), (1,2), (1,0)




Aucun commentaire:

Enregistrer un commentaire