def flatten(lis):
    """Given a list, possibly nested to any level, return it flattened."""
    new_lis = []
    for item in lis:
        if type(item) == type([]):
            new_lis.extend(flatten(item))
        else:
            new_lis.append(item)
    return new_lis
Given a list, possibly nested to any level, return it flattened.
recipes/Python/578948_Flattening_arbitrarily_nested_list/recipe-578948.py