The following code tries to create an integer array filled with n times number 1.
import sys
def foo(n):
if n == 0:
return []
else:
return foo(n-1).append(1)
if __name__ == '__main__':
foo(5)
Executing this program yields in an error:
AttributeError: 'NoneType' object has no attribute 'append'
What am I doing wrong when creating the array?