Q:

Get a running total from a list

I'm reading in items:
for line in sys.stdin:
    line = line.strip()
    data = line.split("-")

If I print data as it is read, it looks like:
['Adam', '5']
['Peter', '7']
['Adam', '8']
['Lucy', '2']
['Peter', '4']

How can I get a running total for each unique name, such my new list would look like:
['Adam', '13'],
['Peter', '11'],
['Lucy', '2']

A:

Use a collections.Counter() to count the occurrences:
import collections

lines = [['Adam', '5'],
         ['Peter', '7'],
         ['Adam', '8'],
         ['Lucy', '2'],
         ['Peter', '4']]

counter = collections.Counter()
for data in lines:
    counter[data[0]] += int(data[1])

print(counter)

You'll get:
Counter({'Adam': 13, 'Peter': 11, 'Lucy': 2})

