Time Conversion

  • + 0 comments

    Python 3 sol:

    def timeConversion(s):
        if s.endswith('PM') and s[:2] != '12':
            s = str(int(s[:2]) + 12) + s[2:]
        elif s.endswith('AM') and s[:2] == '12':
            s = '00' + s[2:]
        return s.strip('PMA')