samedi 28 septembre 2019

How to get keys and values from dictionary python

I have my dictionary as per below my_dict = {4: 8, 3: 11, 4: 10, 5: 10, 8: 5, 9: 5, 10: 10, 5: 2}

I am trying to figure out how to get a sorted list when key == value and also when itinerating the value becomes the key. The result then is

[[2,5,4,8],[10]]

Any ideas?

Aucun commentaire:

Enregistrer un commentaire