Time Conversion

  • + 0 comments

    python3 solution using modulo:

    def timeConversion(s):
        
        if s[-2:] == 'AM':
            h = int(s[0:2]) % 12
        else:
            h = int(s[0:2]) % 12 + 12
        
        h = '0' + str(h) if h < 12 else str(h)
        return h + s[2:6] + s[6:8]