Skip to content

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

Output:

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


print(function_1(10))

Output: 200

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

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

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

1 thought on “How to use return value in another function Python | Example code”

  1. I’m wondering if there is a way to call the return value of the function in the same way it was called in the past via print statement

Leave a Reply

Your email address will not be published. Required fields are marked *