Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Too pedantic solution in Clear category for Time Converter (12h to 24h) by kkkkk
def time_converter(time):
"""Return string converted from time in 12-hour to 24-hour format."""
time_str, am_pm = time.split()
hour, minutes = time_str.split(':')
hour = int(hour)
if am_pm[0] == 'p' and hour < 12:
hour += 12
elif am_pm[0] == 'a' and hour == 12:
hour = 0
return f'{hour:02d}:{minutes}'
Jan. 2, 2020
Comments: