def convert_time(time):
split_time = time.split()<EOL>try:<EOL><INDENT>am_pm = split_time[<NUM_LIT:1>].replace('<STR_LIT:.>', '<STR_LIT>')<EOL>time_str = '<STR_LIT>'.format(split_time[<NUM_LIT:0>], am_pm)<EOL><DEDENT>except IndexError:<EOL><INDENT>return time<EOL><DEDENT>try:<EOL><INDENT>time_obj = datetime.strptime(time_str, '<STR_LIT>')<EOL><DEDENT>except ValueError:<EOL><INDENT>time_obj = datetime.strptime(time_str, '<STR_LIT>')<EOL><DEDENT>return time_obj.strftime('<STR_LIT>')<EOL>
Convert a time string into 24-hour time.