Simple flatten
Input
flatten_one_level([1, [2, 3], 4])
Output
[1, 2, 3, 4]
The inner list [2, 3] is flattened into the outer list; other elements kept.
Full lesson preview
Flatten only the top-level nested lists inside a list, preserving deeper nested structures and non-list items.
Problem statement
Task
Examples
Input
flatten_one_level([1, [2, 3], 4])
Output
[1, 2, 3, 4]
The inner list [2, 3] is flattened into the outer list; other elements kept.
Input format
Output format
Constraints
Samples
Input
flatten_one_level([[1,2],[3],[4]])
Output
[1, 2, 3, 4]
All top-level lists are flattened into a single list.