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.
if 'PM' in s[2]:
s[2]=s[2][:2]
if s[0]!='12':
s[0]=int(s[0])+12
print(f'{s[0]}:{s[1]}:{s[2]}')
elif 'AM' in s[2]:
s[2]=s[2][:2]
if s[0]=='12':
s[0]='00'
print(f'{s[0]}:{s[1]}:{s[2]}')
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 →
s=input().split(':')
print(s)
if 'PM' in s[2]: s[2]=s[2][:2] if s[0]!='12': s[0]=int(s[0])+12 print(f'{s[0]}:{s[1]}:{s[2]}') elif 'AM' in s[2]: s[2]=s[2][:2] if s[0]=='12': s[0]='00' print(f'{s[0]}:{s[1]}:{s[2]}')