def convert_24hour(time):
    """
     Takes 12 hour time as a string and converts it to 24 hour time.
    """
    # Check if 12:00 AM
    if time[-2:] == "AM" and time[:2] == "12":
        return "00" + time[2:-2]

    # Remove AM
    elif time[-2:] == "AM":
        return time[:-2]

    # Check if 12:00 PM
    elif time[-2:] == "PM" and time[:2] == "12":
        return time[:-2]

    else:
        # add 12 hours and remove PM
        return str(int(time[:2]) + 12) + time[2:-2]