s = 13420 hours, remainder = divmod(s, 3600) minutes, seconds = divmod(remainder, 60) print '{:02}:{:02}:{:02}'.format(int(hours), int(minutes), int(seconds)) # result: 03:43:40