Issue
There is something in Python that has been bugging me for a long time. I can't figure out how to pass parameters from one function to the functions that are defined inside of that function.
def func1(arg1):
def func2(arg1):
print(arg1)
func2()
var1 = 123
func1(var1)
Here func1 and func2 should have the same parameters but don't.
Solution
You have only missed the argument in the call of func2
. The code below highlights your forgetfulness:
def func1(arg1):
def func2(arg1):
print(arg1)
# ---> here you have missed the argument
func2(arg1)
var1 = 123
func1(var1)
Answered By - frankfalse
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.