Convert time to number seconds without decimal part

-1

I'm having trouble rendering the result of a specific time transformation, in the form HH:MM:SS , all in seconds. The result is correct, but with .0 at the end, which makes my response invalid on a site.

My code:

horario = input()
hora = float(horario[0:2])* int(3600)
minuto = float(horario[3:5])* int(60)
segundo = float(horario[6:8])
C = float(hora + minuto + segundo)
print(int(C))

# Saída: 18711.0
    
asked by anonymous 18.08.2018 / 22:59

1 answer

0

Reading your code and testing it, the answer is an integer value even, because there is no way out float if you are converting at the end, in any case I set an example just to compare, I used the split just to stay in one vector every hour / min / sec so you do not need to do the string breaks, it separates in every occurrence of the character ':'

hora = input()
vetor = hora.split(":")
soma = 0
soma += int(vetor[0])*3600
soma += int(vetor[1])*60
soma += int(vetor[2])
print(soma)
    
22.08.2018 / 20:41