I have a list of dictionaries. Each dictionary has an integer key and a tuple value. I would like to summarize all the elements located in a specific place in the tuple.
Example:
myList = [{1000:("a",10)},{1001:("b",20)},{1003:("c",30)},{1000:("d",40)}]
I know I can do something like:
sum = 0 for i in myList: for i in myList: temp = i.keys() sum += i[temp[0]][1] print sum
Is there a more pythonic way to do this? Thanks
python
Pavan
source share