Last iteration of function in python


def neumann_set( n ):
    if n == 0:
        return set()
    else:
        return neumann_set(n-1).add( neumann_set(n-1) )

How do I retrieve Neumann_set(n-1)

Heat Jack asked:

“How do I retrieve Neumann_set(n-1)”

You call neumann_set(n-1). You need to make sure n has a value, of course.

n = 15
result = neumann_set(n-1)  # like neumann_set(14)

But your code won’t work because sets are not hashable, so your sets cannot contain sets. It will work for n=0:

neumann_set(0)  # correctly returns an empty set

but for any value above 0, it will fail with a TypeError.

If you explain what a Neumann set is, perhaps we can help you program it correctly.