Python recursion with list returns None [duplicate]

Solution 1:

You don't return anything in the else clause:

    else:
        return foo(a)