I am trying to create a dictionary in which i have to keep incrementing a value
So i am trying the following:
from collections import defaultdict
test = defaultdict(dict)
for item in debitlist:
if not something:
test[item['name']]['count'] += 1
test[item['name']]['amount'] += item['name']['amount']
I am trying to get a dictionary like
{ "Krishna" : { "count" : totalcount, "amount" : totalamount } }
I am getting Keyerror for count. How to resolve this and get what i want