Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
No time module solution in Clear category for Time Converter (12h to 24h) by CDG.Axel
def time_converter(time):
h, m = map(int, time[:-5].split(':'))
return f'{h % 12 + 12 * ("p" in time):02}:{m:02}'
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert time_converter('12:30 p.m.') == '12:30'
assert time_converter('9:00 a.m.') == '09:00'
assert time_converter('11:15 p.m.') == '23:15'
print("Coding complete? Click 'Check' to earn cool rewards!")
Dec. 4, 2021
Comments: