2016-08-07 9 views
1

に別の目的球の引数として1つの関数の戻り値を渡したい:私はこれが私のコードでのpython

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())) 

は、今ここで私はfun_twoへの引数としてfun_oneの戻り値を渡したいです。どうやってするの?

答えて

3

あなたはとしてそれを行うことができます。

def fun_one(x): 
    total = x + 5 
    return total 


def fun_two(y): 
    y += 5 
    return y 

print(fun_two(fun_one(5))) 

それともとしても、それを行うことができます。

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)) 
+0

感謝を!私のansを持っている:) – Mohib

0

ので、同じようfun_two()中にあなたfun_one(5)を呼び出します。

# Replace these lines 
fun_one(5) 
print(fun_two(fun_one())) 

# With this 
print(fun_two(fun_one(5))) 
関連する問題