def flatten(x):
    """ flatten():  turns nested list or tuple into single list """
    result = []
    if isinstance(x, str):
        result = x
    else:
        for el in x:
            if hasattr(el, "__iter__") and not isinstance(el, str):
                result.extend(flatten(el))
            else:
                result.append(el)
    return result