-1

is it possible to do something like that?

def multireturn():
  return 1, 2, 3

def add(a, b, c):
  return a+b+c

add(multireturn())

When I tried it, it errored as it sees only one argument. Thanks!

Skye
  • 300
  • 2
  • 14

2 Answers2

6

You need to unpack the tuple returned from the first function to make it behave as sequential positional arguments to the second. The * unpacking operator allows this:

add(*multireturn())
ShadowRanger
  • 143,180
  • 12
  • 188
  • 271
2

you need to add the unpacking operator * to unpack the tuple returned from the first function . try :

add(*multireturn())
tawfikboujeh
  • 135
  • 1
  • 13