input: Write a python function to flatten a nested list.
  assert flatten([[1, 2], [3, [4, 5]]]) == [1, 2, 3, 4, 5]
  assert flatten([1, [2, [3, [4, 5]]]]) == [1, 2, 3, 4, 5]
  assert flatten([]) == []
  assert flatten([[[1], [2]], [[3], [4, [5]]]]) == [1, 2, 3, 4, 5]
output: def flatten(nested_list):
      flat_list = []
      for item in nested_list:
          if isinstance(item, list):
              flat_list.extend(flatten(item))
          else:
              flat_list.append(item)
      return flat_list