I am trying to create custom permutations in a list (mainly to mess around with recursion in python). Right now I get this error when I run my code:
TypeError: 'NoneType' object is not iterable
Before I added in the list copying, I was getting this:
AttributeError: 'NoneType' object has no attribute 'append'
def findPermutations (size, max, curr_perm):
if not curr_perm or len(curr_perm) < size:
for i in range(1,max):
new_arr = list(curr_perm)
findPermutations(size, max, new_arr.append(i))
else:
return curr_perm
print(findPermutations(2,3,[]))
I was hoping to return a bunch or permutations. What am I doing wrong here?
NoneTypemeans you're trying to access something that doesn't exist. In other languages known asnull. Use a debugger and check the values.new_arr.append(i)returnsNone. Append, then pass the list into the function