code: def flatten(l):
      
      l = list(l)
      i = 0
      while i < len(l):
          while isinstance(l[i], list):
              if not l[i]:
                  l.pop(i)
                  i -= 1
                  break
              else:
                  l[i:i + 1] = l[i]
          i += 1
      return l
docs: Flattens a hierarchy of nested lists into a single list containing all elements in order
  
      :param l: list of arbitrary types and lists
      :returns: list of arbitrary types