1flat_list = [item for sublist in l for item in sublist]
2
3#which is equivalent to this
4flat_list = []
5for sublist in l:
6 for item in sublist:
7 flat_list.append(item)
1# idiomatic python
2
3# using itertools
4import itertools
5
6list_of_list = [[1, 2, 3], [4, 5], [6]]
7chain = itertools.chain(*images)
8
9flattened_list = list(chain)
10# [1, 2, 3, 4, 5, 6]
1l = [[1, 2], [3, 4], [5, 6, 7]]
2flat_list = [item for sublist in l for item in sublist]
3# flat_list = [1, 2, 3, 4, 5, 6, 7]
1# if your list is like this
2l = [['Adela', 'Fleda', 'Owen', 'May', 'Mona', 'Gilbert', 'Ford'], 'Adela']
3
4# then you
5a = []
6for i in l:
7 if type(i) != str:
8 for x in i:
9 a.append(x)
10 else:
11 a.append(i)
12