Write a programExercise 3/4Elementary20 XP

The maximum of a list recursively

Task

Write a recursive function maximum(zoznam) that returns the largest item of a non-empty list. Think of it like this: the maximum of a list is the larger of two values - the first item and the maximum of the rest of the list.

Do not use loops, the max function or sorting.

Examples

  • Call

    print(maximum([3, 9, 2]))

    Expected output

    9

Rules

  • Solve it with recursion - no loops, max or sorting.

After you submit, 5 hidden tests will also check your solution: one item, negative numbers, the maximum at the end, equal items, the list stays the same.

Python starts the first time you run code.

Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.

Input (stdin)

Each line = one call to input().

Output

Hints

Try it yourself first. Each hint reveals a little more - and lowers the reward a little.

Signed out, hints are free - but no XP is awarded either.

Solution

The solution unlocks after the last hint.