Back to task

287 symbols python2
Sun Jun 22 21:15:09 2014 KoukiMino
import sys
lines=map(str,sys.stdin.read().splitlines())
out={}
for line in lines:
	(item,price) = map(str,line.split(' '))
	if out.has_key(item):
		out[item] += int(price)
	else:
		out[item] = int(price)
for item,price in sorted(out.items(),key=lambda x:x[0]):
	print item+" "+str(price)


Leave a comment

Parsed as Markdown

Login to leave a comment