← Back to challenges

Recursion: Array Sum

PythonHardrecursionnumbersarrayslanguage_fundamentals

Instructions

Write a function that finds the sum of a list. Make your function recursive.

Examples

sum_recursively([1, 2, 3, 4]) ➞ 10

sum_recursively([1, 2]) ➞ 3

sum_recursively([1]) ➞ 1

sum_recursively([]) ➞ 0

Notes

  • Return 0 for an empty list.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Narcissistic Number