python_code/time_conversion_basic at main · karthiksalapu/python_code

PHOTO EMBED

Sun Mar 10 2024 12:20:35 GMT+0000 (Coordinated Universal Time)

Saved by @karthiksalapu

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()
content_copyCOPY

https://github.com/karthiksalapu/python_code/blob/main/time_conversion_basic