Suppose I have a dictionary a which is
a = {'a':1,'b':2,'c':3,'d':4,'e':5}
Now If I will give size=2 than the output should be like a list of lists in which each list size should be equal to 2 , last list size doesn’t matter, like in this case it should be like this
[[('a', 1), ('c', 3)], [('b', 2), ('e', 5)], [('d', 4)]]
or if size = 3 than it should be like this [[('a', 1), ('c', 3), ('b', 2)], [('e', 5), ('d', 4)]]
First of all convert your dictionary into a list , which you can do easily like this
than use this method to make the chunks of the list for a given size