Time Conversion

  • + 0 comments

    python without using time module

    def timeConversion(s):
        # Write your code here
        hrs = "12"
        splitted = s.split(":")
        print(splitted)
        if "PM" in splitted[2][2:]:
            if "12" not in splitted[0]:
                hrs = str(int(hrs) + int(splitted[0]))
        if "AM" in splitted[2][2:]:
            if "12" not in splitted[0]:
                hrs = splitted[0]
            else:
                hrs = "00"
        return hrs+":"+splitted[1]+":"+splitted[2][:2]