You are viewing a single comment's thread. Return to all comments →
for python3:
is_pm = s.endswith('PM') time_part = s[:-2] hours = int(time_part[:2])
if is_pm: if hours != 12: hours += 12 else: if hours == 12: hours = 0 military_hours = f"{hours:02d}" result = military_hours + time_part[2:] return result
Seems like cookies are disabled on this browser, please enable them to open this website
Time Conversion
You are viewing a single comment's thread. Return to all comments →
for python3:
is_pm = s.endswith('PM') time_part = s[:-2] hours = int(time_part[:2])