I’m trying to convert a dictionary into a list of values/tuples. I have this code:
list_to_sort = sorted(dictionary.items())
lst = list(list_to_sort)
print(lst)
The output is [('a', 9), ('b', 17), ('c', 17), ('d', 3)]. However, I want to switch the values to make the output this:
[(9, 'a'), (17, 'b'), (17, 'c'), (3, 'd')]
How do I do this?