File size: 443 Bytes
a100cc5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

def flatten_list(my_list: list) -> list:
    """
    Args:
        my_list: list composed of lists (of lists of lists...)

    Returns: flattened list

    """
    flattened_list = []
    for item in my_list:
        if isinstance(item, list) and len(item) > 0:
            print(item)
            flattened_list += flatten_list(item)
        elif not isinstance(item, list):
            flattened_list.append(item)

    return flattened_list