Python Time Format Conversion

Python function that converts 12-hour to 24-hour time format and vice versa.

Write a function in Python that takes a time string in either 12-hour 'hh:mm am/pm' format or 24-hour 'hh:mm' format and converts it to the other format. In a 24-hour format, the time is specified from 0000 (midnight) to 2359, while in a 12-hour format, it goes from 12:00 am to 11:59 pm. 'am' stands for ante meridiem (pre-noon) while 'pm' stands for post meridiem (post-noon). ### Parameters `time` (string): The time string that needs to be converted. ### Returns A string that represents the time in the converted format. ### Examples ```python # 12:00 am in 12-hour format is equivalent to 00:00 in 24-hour format time_conversion("12:00 am") # Returns: "00:00" # 6:20 pm in 12-hour format is equivalent to 18:20 in 24-hour format time_conversion("6:20 pm") # Returns: "18:20" # 21:00 in 24-hour format is equivalent to 9:00 pm in 12-hour format time_conversion("21:00") # Returns: "9:00 pm" # 5:05 in 24-hour format is equivalent to 5:05 am in 12-hour format time_conversion("5:05") # Returns: "5:05 am" ``` ## Template Code ```python def time_conversion(time): pass # Test cases print(time_conversion("12:00 am")) # "00:00" print(time_conversion("6:20 pm")) # "18:20" print(time_conversion("21:00")) # "9:00 pm" print(time_conversion("5:05")) # "5:05 am" ```