code: def _flatten(lst):
      
      if not isinstance(lst, (list, tuple)):
          return [lst]
      result = []
      for item in lst:
          result.extend(_flatten(item))
      return result
docs: Flatten a nested list.