input: Write a python function to calculate the median of a list of numbers.
  assert median([4, 5, 6, 7, 8, 1, 2]) == 4.5
  assert median([3, 1, 2]) == 2
  assert median([10, 20, 30, 40, 50]) == 30
  assert median([1, 2, 3, 4]) == 2.5
output: def median(lst):
      lst.sort()
      n = len(lst)
      mid = n // 2
      if n % 2 == 0:
          return (lst[mid - 1] + lst[mid]) / 2
      else:
          return lst[mid]