I have got pretty simple list:
example_list = [
{'points': 400, 'gold': 2480},
{'points': 100, 'gold': 610},
{'points': 100, 'gold': 620},
{'points': 100, 'gold': 620}
]
How can I sum all gold values? I'm looking for nice oneliner.
Now I'm using this code (but it's not the best solution):
total_gold = 0
for item in example_list:
total_gold += example_list["gold"]
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…