Combine list elements
I'm working on python list and ran into a problem. I have a list of tuple.
oldlist= [('A', 30), ('B', 20), ('A', 10), ('B', 20), ('C', 20), ('D', 10), ('B', 40)]
How can I merge them and add up the number regarding to their letter. For example, total A score is 30 + 10 = 40 B score is 20 + 20 + 40 = 80 ... so on and so on.
I want my new list looks like this
newlist = [('A', 40),('B', 80),('C',20),('D',10)]