How to convert hh:mm:ss to minutes in Python

1 Answer

0 votes
def hhmmsstominutes(hhmmss):
    time = list(map(int, hhmmss.split(':')))
    
    return (time[0] * 60) + time[1] + (time[2] / 60)


print(hhmmsstominutes("2:30:00"))
print(hhmmsstominutes("2:35:30"))
print(hhmmsstominutes("5:00:45"))


       
'''
run:
       
150.0
155.5
300.75
   
'''

 



answered Apr 17 by avibootz

Related questions

1 answer 30 views
1 answer 35 views
1 answer 34 views
1 answer 31 views
1 answer 31 views
...