0

i want to set the output of a function as the input of the other function, like this

def math(a,b):
some code...
return(a,b,c)

def pro(a,b,c):
some code
return(e)
#and then call function by:
pro(math(a,b))

however,

TypeError: pro() missing 2 required positional arguments: 'b' and 'c'

Can you tell me how can i change my code?

once
  • 1,369
  • 4
  • 22
  • 32

2 Answers2

0

Just use asterisk:

pro(*math(a,b))
pss
  • 736
  • 3
  • 7
  • 14
0

You can unpack the returned value as the arguments:

args = math(3, 4) # returns (a, b, c)
print pro(*args) # pro(a, b, c)
Malik Brahimi
  • 16,341
  • 7
  • 39
  • 70