I am baffled by this and I suspect I am making an extremely trivial mistake but here it is anyway:
I want to recursively fill a list with elements. Let's make a simple example. I just want to invert a list in the following manner:
def recurse(x, remaining):
if len(remaining) == 0:
assert x == [3, 2, 1] # This does not raise????
return x
x.append(remaining.pop())
recurse(x, remaining)
x = [1, 2, 3]
y = recurse([], x)
However y
is None, even when I explicitly check that the value is as expected JUST before returning. What am I missing?