dimanche 10 février 2019

How to generate a random value for key in dict

So, i need to generate a random value for my keys in dict. Wheres key is a letter. Like this a:20, b:121 ... z:[random value]

If i use shuffle, then python sorted all values and this example doesn't work

value = list(range(97,122))
random.shuffle(value)

dic = {chr(x): x - 65 for x in value} 




Aucun commentaire:

Enregistrer un commentaire