Time Conversion

  • + 0 comments

    My solution with Python:

    def timeConversion(s):
        
        h = int(s[0:2])
        
        if s[-2:]=='PM':
            h+=12
            
        if s[0:2] == '12':
            h-=12
        
        converted = str(h).zfill(2) + s[2:-2]
        
        return converted