timefile = file("times.txt", "r") total_secs = 0 for line in timefile: # break line up into hours, minutes, seconds h,m,s = line.rstrip().split(":") # calculate total seconds on this line secs = 3600*int(h) + 60*int(m) + int(s) total_secs += secs print secs timefile.close() print "Total:", total_secs, "seconds"