In [1]:
def get_sec(s):
l = s.split(':')
return int(l[0]) * 3600 + int(l[1]) * 60 + int(l[2])
print get_sec('2:15:30')
print get_sec('0:10:00')
print get_sec('0:00:30')
Line by line explanations of how things work in Python
def get_sec(s):
l = s.split(':')
return int(l[0]) * 3600 + int(l[1]) * 60 + int(l[2])
print get_sec('2:15:30')
print get_sec('0:10:00')
print get_sec('0:00:30')
8130 600 30