Write a program to divide dictionary and its keys into K equal dictionaries and print it
Topic: Write a program to divide dictionary and its keys into K equal dictionaries and print it
Solution
test_dict = {"Gfg": 20, "is": 36, "best": 100} print("The original dictionary is : " + str(test_dict)) K = 4 s=list(test_dict.keys()) print(s) q=list(test_dict.values()) t=[] for i in q: t.append(i//K) print(t) q=[] d={} for i in range(K): for i in range(0,len(s)): d[s[i]] = t[i] q.append(d) print(q)
List all Python Programs