additon of multiple duration timestamps python

Solutions on MaxInterview for additon of multiple duration timestamps python by the best coders in the world

showing results for - "additon of multiple duration timestamps python"
Luciano
04 Sep 2016
1timeList = [ '0:00:00', '0:00:15', '9:30:56' ]
2totalSecs = 0
3for tm in timeList:
4    timeParts = [int(s) for s in tm.split(':')]
5    totalSecs += (timeParts[0] * 60 + timeParts[1]) * 60 + timeParts[2]
6totalSecs, sec = divmod(totalSecs, 60)
7hr, min = divmod(totalSecs, 60)
8print "%d:%02d:%02d" % (hr, min, sec)