An alternative way would be to re-create the topic and timelists, using dict to summarize the time of repeated items (I assume that the subjects are strings, i.e. hashed).
subjects=['math','english','necromancy','philosophy','english','latin','physics','latin'] time=[1,2,3,4,5,6,7,8] tuples=zip(subjects,time) my_dict={} for subject,t in tuples: try: my_dict[subject]+=t except KeyError: my_dict[subject]=t subjects,time=my_dict.keys(), my_dict.values() print subjects,time
source share