As I said the value of n is generated with timestamp. So it doesn't work. Try the following which results empty list:
@scidam,
I just tried with standard library. And it works fine. But I'm not sure if I understand them.
@SheeppOSU,
I would love to use your method coz, I don't need to import other library. So, can you please update your answer once again with the given timestamp?
List = [ { "name": "John", "m": "good", "n": 1561895746657 }, { "name": 'Alina', "m": "good", "n": 1561895746657 }, { "name": "Peter", "m": "bad", "n": 1561895746657 }, { "name": 'Mary', "m": "bad", "n": 1561895746657 }, { "name": "Olivia", "m": "bad", "n": 1561872416143 }, { "name": "Ruby", "m": "bad", "n": 1561872416143 }, { "name": "Sukuyomi", "m": "good", "n": 1561872416143 }, { "name": "Furuhashi", "m": "good", "n": 1561872416143 } ] NewList = [{'g' : [], 'b' : []}] for Dict in List: if Dict['n'] == len(NewList): NewList[Dict['n'] - 1][Dict['m'][0]].append(Dict) else: NewList.append({'g' : [], 'b' : []}) print(NewList)
@scidam,
I just tried with standard library. And it works fine. But I'm not sure if I understand them.
@SheeppOSU,
I would love to use your method coz, I don't need to import other library. So, can you please update your answer once again with the given timestamp?