#!/usr/bin/python
###########
file='lista2'
a = open(file)
b = a.readlines()
a.close
b.sort()
c = [c[:-1] for c in b]
d=len(b)
e=0
aak=0
tot=0
###########
grupsum = open('sortirano', 'w')
while d>e:
bbkv=c[e].split(';')
if bbkv[0]!='':
intbbkv=int(bbkv[1])
if aak and bbkv[0] != aak:
grupsum.write(aak+'='+str(tot)+'\n')
print aak+'='+str(tot)
tot=0
aak=bbkv[0]
tot+=intbbkv
e+=1
if d==e:
print aak+'='+str(tot)
grupsum.write(aak+'='+str(tot)+'\n')
grupsum.close()
if aak and bbkv[0] != aak:
Ova poruka je od: https://arhiva.linux.hr/newbb/viewtopic.php?forum=8&topic_id=2355&post_id=14712