-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!

0

2 Answers 2

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())
Sign up to request clarification or add additional context in comments.

Comments

2

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

add(*multireturn())

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.