implement flatten arrays given an array that may contain nested arrays produce a single resultant array return list returns iterator takes as input multi dimensional iterable and returns generator which produces one dimensional output return list tail recursion produce the result returns iterator takes as input multi dimensional iterable and returns generator which produces one dimensional output
from collections.abc import Iterable



def flatten(input_arr, output_arr=None):
    if output_arr is None:
        output_arr = []
    for ele in input_arr:
        if not isinstance(ele, str) and isinstance(ele, Iterable):
            flatten(ele, output_arr)    
        else:
            output_arr.append(ele)      
    return output_arr



def flatten_iter(iterable):
    
    for element in iterable:
        if not isinstance(element, str) and isinstance(element, Iterable):
            yield from flatten_iter(element)    
        else:
            yield element