Time Conversion

  • + 0 comments

    Python

    def timeConversion(s):
        # Write your code here
        am = s[-2:]
        time_f = s[:-2].split(':')
        if am=='AM':
            if time_f[0]=='12':
                time_f[0]='00'
        else:
            if time_f[0]!='12':
                time_f[0]= str(12+int(time_f[0]))
        return ':'.join(time_f)