Reputation: 467
This is my code:
def fun_one(x):
total = x + 5
return total
def fun_two(y):
y += 5
return y
fun_one(5)
print(fun_two(fun_one()))
Now here I want to pass fun_one
's return value as argument to fun_two
. How to do it?
Upvotes: 1
Views: 85
Reputation: 8683
Call your fun_one(5)
inside fun_two()
like so:
# Replace these lines
fun_one(5)
print(fun_two(fun_one()))
# With this
print(fun_two(fun_one(5)))
Upvotes: 0
Reputation: 2699
You can do it as:
def fun_one(x):
total = x + 5
return total
def fun_two(y):
y += 5
return y
print(fun_two(fun_one(5)))
Or you can also do it as:
def fun_one(x):
total = x + 5
return total
def fun_two(y):
y += 5
return y
temp=fun_one(5)
print(fun_two(temp))
Upvotes: 3