We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
**Code in Python **
def timeConversion(s):
h=s[:2]
se=s[-2:]
rest=s[2:-2]
ho=int(h)
if se=='AM':
if ho==12:
ho=0
else:
if ho != 12:
ho += 12
return f"{ho:02}{rest}"
Cookie support is required to access HackerRank
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 →
**Code in Python ** def timeConversion(s): h=s[:2] se=s[-2:] rest=s[2:-2] ho=int(h) if se=='AM': if ho==12: ho=0 else: if ho != 12: ho += 12 return f"{ho:02}{rest}"