Take a look at the following code to see why you get the error,
>>> x = [].append(1) >>> x is None True
When added to the list, the return value is None ! So you should do something like this,
def foo(n): if n == 0: return [] else: return foo(n-1) + [1]
Using the + operator does look like calling extend on a list, for which the return value is a new list, unlike append .
>>> x = [1] + [1] >>> x [1, 1]
NOTE. Obviously, for this simple example, you should simply use
>>> [1] * 6 [1, 1, 1, 1, 1, 1]
This is normal for immutable int , but if you are dealing with objects where you do not want to refer to the same,
>>> [1 for _ in range(6)] [1, 1, 1, 1, 1, 1]
But I assume that you write this to practice recursive solutions, etc.