How to use return value in another function Python | Example code

Simply call a function to pass the output into the second function as a parameter will use the return value in another function python.

Example pass a function in another function in Python

Simple example code, using return value inside another function.

def fun1(a):
    res = a + 1
    return res

def fun2(c):
    res = c * 2
    return res

output = fun1(fun2(1))


How to use return value in another function Python

How can I use a function output as an input of another function in Python?

Answer: You directly call one function in the other, here is an example for calling a function inside of a function.

def function_1(n):
    v = n * n
    num = function_2(v)
    return num

def function_2(a_number):
    a_number = a_number * 2
    return a_number


Output: 200

Do comment if you have any doubts and suggestions on this Python return topic.

Note: IDE: PyCharm 2021.1.3 (Community Edition)

Windows 10

Python 3.7

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.