Nested list into flat list python
def flatten_list(_2d_list): flat_list = [] # Iterate through the outer list for element in _2d_list: if type(element) is list: # If the element is of type list, iterate through the sublist for item in element: flat_list.append(item) else: flat_list.append(element) return flat_list nested_list = [[1, 2, 3, 4], [5, 6, 7], [8, 9, 10]] print('Original List', nested_list) print('Transformed Flat List', flatten_list(nested_list))