Concatenation of inner lists or ints [duplicate]
问题 This question already has answers here : Flattening a shallow list in Python [duplicate] (23 answers) Flatten an irregular list of lists (44 answers) Closed 6 years ago . I feel like I'm missing something obvious, but there it is... I would like to go from: lst = [[0, 1, 3, 7, 8, 11, 12], [8, 0, 1, 2, 3, 14], 2] to: output = [0, 1, 3, 7, 8, 11, 12, 8, 0, 1, 2, 3, 14, 2] I can do this with a for loop such as: output = [] for l in lst: if hasattr(l, '__iter__'): output.extend(l) else: output