I want to execute a number of functions, in another function.
I’m trying to achieve something like this:
def first(thisString,thisNumber): print(thisString,thisNumber) def second(a,b,c): print(a+b+c) def runningOne(*args): for x in args: x[0](x[1]) one=[first,("try",15)] two=[second,(4,3)] runningOne(one,two)
But I don’t know how to pass the arguments in the “runningOne” function.
Thanks,
Advertisement
Answer
you forgot to put an asterisk,
def first(thisString,thisNumber): print(thisString,thisNumber) def second(a,b,c): print(a+b+c) def runningOne(*args): for x in args: x[0](*x[1]) one=[first,("try",15)] two=[second,(4,3, 8)] runningOne(one,two)
That’s the fixed code, you had to put an asterisk before the x[1]
and you also forgot to specify the third number in two
.