mardi 30 juin 2020

Shuffle dictionaries of sets in Python

I am trying to shuffle dictionaries of sets. This is the set which I want to shuffle randomly

{'1': ['IMG_0001.png', 'IMG_0002.png', 'IMG_0003.png', 'IMG_0004.png'], 
 '2': ['IMG_0020.png', 'IMG_0021.png', 'IMG_0022.png', 'IMG_0023.png'], 
 '3': ['IMG_0051.png', 'IMG_0052.png', 'IMG_0053.png', 'IMG_0054.png']} 

Output should be somewhat like this below

{'1': ['IMG_0001.png', 'IMG_0002.png', 'IMG_0053.png', 'IMG_0054.png'], 
 '2': ['IMG_0020.png', 'IMG_0021.png', 'IMG_0022.png', 'IMG_0023.png'], 
 '3': ['IMG_0003.png', 'IMG_0004.png', 'IMG_0051.png', 'IMG_0052.png']}

Tried using random.shuffle() in python but not getting as expected. Can anyone help me. I am a new beginner in python. Thank you for your help.




Aucun commentaire:

Enregistrer un commentaire