0

Let's say that there was functionA:

def functionA():
  return 'foo','bar'

and there was functionB:

def functionB(first,second):
  print(first)
  print(second)

and I wanted to use the output of function A as an argument for function B, like this:

functionB(functionA())

But that doesn't work because python thinks that functionB expects 2 arguments and function A is only one argument, and it gives me an error. How do I solve this? Thank you in advance.

someguy
  • 21
  • 2
  • 5
    `functionB(*functionA())` – rdas Apr 01 '21 at 09:47
  • @rdas where can I find more information about this? what is it called? thank You in advance – Matiiss Apr 01 '21 at 09:49
  • 2
    [Argument packing & unpacking](https://realpython.com/python-kwargs-and-args/) – rdas Apr 01 '21 at 09:50
  • Or [passing a tuple in *args](https://stackoverflow.com/questions/46794115/passing-a-tuple-in-args) (which links to the extensive [What does ** (double star/asterisk) and * (star/asterisk) do for parameters?](https://stackoverflow.com/questions/36901/what-does-double-star-asterisk-and-star-asterisk-do-for-parameters)) – Tomerikoo Apr 01 '21 at 09:52

0 Answers0