Hackbright Code Challenges

Count List Recursively

Count List Recursively

Whiteboard

Medium

Challenge

Easier

Concepts

Recursion

Download

count-recursively.zip

Solution

Count List Recursively: Solution


Count the number of items in a list, using recursion.

For example:

>>> count_recursively([])
0

>>> count_recursively([1, 2, 3])
3

We’ve written a file, countrecursively.py, with a function, count_recursively:

def count_recursively(lst):
    """Return number of items in a list, using recursion."""

However, this is unimplemented.