input: Write a function to find the median of a list of numbers.
  assert median([5, 6, 7, 8, 9]) == 7
  assert median([1, 2, 3, 4, 5, 6]) == 3.5
  assert median([10, 20, 30, 40]) == 25
output: def median(numbers):
      sorted_numbers = sorted(numbers)
      n = len(sorted_numbers)
      mid = n // 2
      
      if n % 2 == 0:
          return (sorted_numbers[mid - 1] + sorted_numbers[mid]) / 2
      else:
          return sorted_numbers[mid]