(Jul-01-2019, 06:43 PM)bhojendra Wrote: As in my initial post, I want the result as like:
I asked why you want result like that? What are the benefits of new structure over old one?
old = [{'name': 'John', 'm': 'good', 'n': 1}, {'name': 'Alina','m': 'good', 'n': 1}, {'name': 'Olivia', 'm': 'bad', 'n': 2}, {'name': 'Ruby', 'm': 'bad','n': 2}] new = [{'g': [{'name': 'John', 'n': 1}, {'name': 'Alina', 'n': 1}]}, {'b': [{'name': 'Olivia','n': 2},{'name': 'Ruby','n': 2}]}]Old list dictionaries have exactly the same structure, new list dictionaries not (some have key 'g', some key 'b' and some probably both). You must be extra careful to not run into KeyError while accessing data.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.