convert number to time python

time = 72.345.
​
hours = int(time)
minutes = (time*60) % 60.
seconds = (time*3600) % 60.
​
print("%d:%02d.%02d" % (hours, minutes, seconds))
>> 72:20:42.

Here is what the above code is Doing:
1. We start by converting the time into an integer, which gives us the number of hours.
2. Then we use the modulo operator (%) to find the number of minutes. This gives us the remainder when we divide the time by 60 (the number of minutes in an hour).
3. Finally, we use the modulo operator again to find the number of seconds. This gives us the remainder when we divide the time by 3600 (the number of seconds in an hour).
4. We then use string formatting to print the time in the HH:MM:SS format.

Task
You are given the time in AM/PM format. Convert this into a 24 hour format.

Note: “12:00:00AM” on a 12-hour clock is “00:00:00” on a 24-hour clock. “12:00:00PM” on a 12-hour clock is “12:00:00” on a 24-hour clock.

Input Format
A single string containing a time in 12-hour clock format (i.e.: hh:mm:ssAM or hh:mm:ssPM), where 01≤hh≤12.

Output Format
Convert and print the given time in 24-hour format, where 00≤hh≤23.

Sample Input
07:05:45PM

Sample Output
19:05:45

Explanation
7 PM is after noon, so you need to add 12 hours to it. 12 + 7 = 19. Minutes and seconds do not change in 12-24 hour time conversions, so the answer is 19:05:45.