def newfunc(n): def myfunc(x): return x + n return myfunc new = newfunc(100) print(new) 

Displays:

 <function newfunc.<locals>.myfunc at 0x000001FF3E5A0B70> 

Expect exit number 200, but not in the console.

Everything is good in the console:

 def newfunc(n): def myfunc(x): return x + n return myfunc new = newfunc(100) new(200) 
  • one
    and what was the expected output? What is the question? - Grundy

1 answer 1

The newfunc function returns a function .

Therefore, the output of print is appropriate.

To get the value of this function, you need to call it, for example:

 def newfunc(n): def myfunc(x): return x + n return myfunc new = newfunc(100) print(new(100)) 

In this case 200 will be displayed.