Reputation: 733
I was trying to pass two variables returned from one function to the next function but but I'm not really understanding what am I missing, i always get the error -
TypeError: Function2() takes exactly 2 arguments (0 given)
My Code:
Function1(arg1, arg2):
# This two args to this function are taken from the user and some work is done here and this function will return two things as output (my_list1 is a list) -
return my_list1, count
Function2 (argg1, argg2):
# This function will get the first and second argument from the previous function (Function1)
def main():
Function1(list1, count1)
myfinal_list, final_count = Function1()
Function2(myfinal_list, final_count)
if __name__== "__main__":
main()
How can I achieve this? What would I have to do to make sure data from the first function will be sent to the second function? Thank you!
Upvotes: 1
Views: 508
Reputation:
You're very close, but just missing one part:
In short, you have to include the arguments when calling the function. For instance, in the line: myfinal_list, final_count = Function1()
you don't call either argument.
Accordingly, main()
should be rewritten as follows:
def main():
myfinal_list, final_count = Function1(list1, count1)
Function2(myfinal_list, final_count)
Upvotes: 2
Reputation: 181270
Try this:
def main():
myfinal_list, final_count = Function1(list1, count1)
Function2(myfinal_list, final_count)
Since this sentence myfinal_list, final_count = Function1()
will give you an error because you are calling a Funcion1
with no arguments (while 2 are expected).
Upvotes: 2