I am trying to write a recursive function that takes a number n and some value, let's say 'a', and recursively builds a list made up of n 'a's.
So, func(4, 'a') returns ['a','a','a','a'].
My internet searches so far have been surprisingly futile. Most examples of list recursion I have found take additional parameters.
I have tried various versions of the following code:
def func(n, a):
if n == 1:
return [a]
else:
return func(n-1, a).append(a)
I keep getting cannot append to NoneType errors on that last return. So func(n-1,a) is returning None.