Created
September 22, 2018 11:13
-
-
Save nikhilkumarsingh/8099993aa3a7c0ebc31e4a889ce581af to your computer and use it in GitHub Desktop.
Randomize dictionary in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
d = {'a':1, 'b':2, 'c':3, 'd':4} | |
for key,val in zip(d.keys(), random.sample(list(d.values()), k=len(d.values()))): | |
d[key] = val | |
print(d) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment