I just want to know a easy way to extract all data with same key "Cat" from the dictionary into another array.
From the below dictionary..
All data with key "Cat: Book" should be in a separate array and key "Cat: pen" in another.
This dictionary is dynamic and more different "Cat" values can come in.
category= [{'Cat':'Book','Item':'LongBook','Qty':'25'},
{'Cat':'Book','Item':'Diary','Qty':'20'},
{'Cat':'Pen','Item':'BallPoint','Qty':'30'}]
It is quite difficult to understand what do you really need. Anyway try to take a look at the following code that uses defaultdict:
Or better use groupby: