L = [{'id':1, 'quantity':1}, {'id':2, 'quantity':2}, {'id':1, 'quantity':3}]
I want to add quantity base on id ,
So for the list above I would like the output to be:
[{'id':1,'quantity':4},{'id':2,'quantity':2}]
another example:
L = [{'id':1, 'quantity':1}, {'id':2, 'quantity':2}, {'id':1, 'quantity':2}, {'id':1, 'quantity':3}]
So for the list above I would like the output to be:
[{'id':1, 'quantity':6}, {'id':2, 'quantity':2}]