Closed mynameisvinn closed 6 years ago
we have d, a list of lists.
d
a = [1, 2, 3] b = [4, 5, 6] c = [7, 8, 9] d = [a, b, c] # [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
let's flatten it.
flat_d = [] for sub_list in d: for element in sub_list: flat_d.append(element) print(flat_d) # [1, 2, 3, 4, 5, 6, 7, 8, 9]
we have
d
, a list of lists.let's flatten it.