How Many Values Can a Function Return in Python

A function is not restricted to return a variable, it can return zero, one, two or more values. This is the default property of python to return multiple values/variables which is not available in many other programming languages like C++ or Java.

Can a function in Python return multiple values?

You can return multiple values by bundling those values into a dictionary, tuple, or a list. Python functions can return multiple values. … To return multiple values, you can return either a dictionary, a Python tuple, or a list to your main program.

How can a function return more than one value?

We can return more than one value from a function by using the method called “call by address”, or “call by reference”. In the invoker function, we will use two variables to store the results, and the function will take pointer-type data. So we have to pass the address of the data.

Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest