I have a dictionary containing people and their duration of completing a task. I wish too add their individual times.
office_time_dict = {
"john": ["0:00:30", "0:02:04", "0:00:16"],
"bryan": ["0:00:30", "0:02:04", "0:00:16"],
"mike": ["0:00:30", "0:02:04", "0:00:16"],
}
total_time = 0
for k, v in office_time_dict.items():
office = office_time_dict[k]
for time in office:
timeparts = [int(s) for s in time.split(":")]
total_time += (timeparts[0] * 60 + timeparts[1]) * 60 + timeparts[2]
total_time, sec = divmod(total_time, 60)
hr, min = divmod(total_time, 60)
print("%d:%02d:%02d" % (hr, min, sec))
current output: 0:02:50, 0:02:52, 0:02:52
Confused as to what I am doing wrong since all outputs should be the same for john, bryan, and mike but bryan and mike are off by 2 seconds