Time Conversion

  • + 0 comments

    Python

    def timeConversion(s):
        hour = s[0:2]
        am_pm = s[8:10]
    
        if hour == "12":
            if am_pm == "AM":
                hour = "00"
        elif am_pm == "PM":
            hour = str(int(hour)+12)
        return f"{hour}{s[2:8]}"