A one-level flatten turns a sequence of groups into a sequence of members. Deeper lists remain members in their own right.
Worked example
nested = [[1, 2], [3], [4, 5]]
print([item for row in nested for item in row])Result
[1, 2, 3, 4, 5]Implementation notes
A string is iterable too. If a group unexpectedly becomes a string, a generic flattening loop can turn a label into individual characters.
Try it yourself
Include an empty group and a group containing another list.
Open the Python example →Editorial date April 25, 2026 · Published December 6, 2026