CJCoding With Joseph
15free / daySign inCreate account

Reverse A List Recursively

Write reverse_list(values: list[int]) -> list[int] that returns a new list with the items in reverse order, by recursion and without the [::-1] slice: an empty list reverses to an empty list; otherwise the result is the reversed rest of the list (the slice values[1:]) followed by the first item wrapped as a one-item list, joined with the plus operator. Do NOT write a main block or any top-level test code; the tests construct the calls. Input: one line of integers separated by spaces (it may be empty), which the tests read into a list and pass to your function before printing the list it returns.

Expected Output:

[3, 2, 1]

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

Hints3 available
Topics:
RecursionSlicing
📥 Auto-Input:
1 2 3\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.