import math
import os
import random
import re
import sys
# Complete the 'timeConversion' function below.
# The function is expected to return a STRING.
# The function accepts STRING s as parameter.
def timeConversion(s):
TS = s[-2:]
if TS == "PM" and s[:2] != "12":
s = str(12 + int(s[:2])) + s[2:]
if TS == "AM" and s[:2] == "12":
s = "00" + s[2:]
return s[:-2]
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
s = input()
result = timeConversion(s)
fptr.write(result + '\n')
fptr.close()
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter