input: Write a python function to convert 12-hour format time to 24-hour format time.
  assert time24('2:30PM') == '14:30'
  assert time24('12:45AM') == '00:45'
  assert time24('11:59PM') == '23:59'
  assert time24('12:00PM') == '12:00'
  assert time24('7:05AM') == '07:05'
output: def time24(time):
      period = time[-2:]
      hours, minutes = map(int, time[:-2].split(':'))
      
      if period == 'AM':
          if hours == 12:
              hours = 0
      else:
          if hours != 12:
              hours += 12
      
      return f'{hours:02}:{minutes:02}'