Write a Python program that sorts dictionary keys to a list using their values and prints this list.


Topic: Write a Python program that sorts dictionary keys to a list using their values and prints this list.

Solution

test_dict = {'Geeks' : 2, 'for' : 1, 'CS' : 3} 
res = list(sum(sorted(test_dict.items(), key = lambda x:x[1]), ())) 
print("List after conversion from dictionary : ", res)



List all Python Programs