0
Why do functions not work?
When I use this type of code: def my_func(): def other_func(): #some stuff here def another_func(): #stuff my_func() The interpreter says that the nested functions arenât defined, even when Iâve enclosed everything in brackets, corrected my typos, etc etc, the interpreter throws the same error, this is becoming frustrating, someone please help.
6 Answers
+ 3
Primal_Nexus not the best idea to post a code you didn't. mean.
Better paste in codeplayground and link it here.
Ok... finally the answer was the scope problemđđ
+ 2
Primal_Nexus First error is that you cant have empty functions without a body, you would need to include the "pass" statement which does nothing, instead of those comments in the inner functions.
Inner functions like this only exist in the scope of the outer function, meaning you can only call them inside the body of my_func(). Or you can return them from my_func() and use elsewhere.
0
Oma Iâm confused as how this is supposed to help me
0
Because the example code isnât the code that wasnât working