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.
def timeConversion(s):
if s.endswith('AM'):
if s[:2]=='12':
g = '00'
return g + s[2:-2]
return s[:-2]
elif s.endswith('PM'):
if s[:2]=='12':
return (s[:-2])
g = str(int(s[:2])+12)
s = g + s[2:-2]
return s
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 →
py:
def timeConversion(s): if s.endswith('AM'): if s[:2]=='12': g = '00' return g + s[2:-2] return s[:-2] elif s.endswith('PM'): if s[:2]=='12': return (s[:-2]) g = str(int(s[:2])+12) s = g + s[2:-2] return s