In this case, create_discs defined your hanoi function within itself so that num was within its scope (automatically, no need to store anything in a global or a class!) and it returned the inner function so you could call it later.

If create_discs was already supposed to return something, then you could just return a tuple with what it was returning plus the inner function: