← Back to Recursion
Question 594
Largest By Recursion
Largest By Recursion
Complete largest(values: list[int]) -> int so it returns the largest value in a non-empty list by recursion, without max(). This time the recursive case is written for you and the base case is missing: add the check at the top of the body that returns the only item when the list's len() is 1, so the recursion stops instead of running until Python raises a RecursionError. 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, at least one, which the tests read into a list and pass to your function before printing the value it returns.
Expected Output:
9= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
RecursionSlicing
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.