Basic flatten
Input
[[1, 2], [3, 4]]
Output
[1, 2, 3, 4]
Each inner list is expanded one level into the resulting list.
Full lesson preview
Flatten only one level of nesting: turn a list of lists (and/or tuples and scalars) into a single list of elements.
Problem statement
Task
Examples
Input
[[1, 2], [3, 4]]
Output
[1, 2, 3, 4]
Each inner list is expanded one level into the resulting list.
Input format
Output format
Constraints
Samples
Input
[['a'], ['b', 'c'], []]
Output
['a', 'b', 'c']
Empty inner lists contribute nothing; other inner lists are expanded.