CJCoding With Joseph
15free / daySign inCreate account

Flatten A List Of Lists

Write flatten(values: list[list[int]]) -> list[int] that returns one flat list holding every number from every row, in order, by recursion: an empty list of rows flattens to an empty list, and otherwise the result is the first row joined (with the plus operator) to the flattened rest of the rows, the slice values[1:]. Do NOT write a main block or any top-level test code; the tests construct the calls. Input: the first line is the number of rows, then one row per line as integers separated by spaces (a row may be empty), which the tests read into a list of lists and pass to your function before printing the list it returns.

Expected Output:

[1, 2, 3, 4, 5, 6]

= newline. The output ends with a newline — print one after the last line.

Hints3 available
Topics:
RecursionSlicing
📥 Auto-Input:
3\n1 2\n3\n4 5 6\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.