
python - How do I get ("return") a result (output) from a function…
Effectively, there are two ways: directly and indirectly. The direct way is to return a value from the function, as you tried, and let the calling code use that value. This is normally what you want. …
Python return statement - GeeksforGeeks
Dec 10, 2024 · Python allows you to return multiple values from a function by returning them as a tuple: Example: In this example, the fun () function returns two values: name and age. The …
The Python return Statement: Usage and Best Practices
In this step-by-step tutorial, you'll learn how to use the Python return statement when writing functions. Additionally, you'll cover some good programming practices related to the use of …
How can I return two values from a function in Python?
I would like to return two values from a function in two separate variables. For example: def select_choice (): loop = 1 row = 0 while loop == 1: print ('''Choose from the follo...
Returning Multiple Values in Python - GeeksforGeeks
May 2, 2023 · To return multiple values from a generator function, you can use the yield keyword to yield each value in turn. The generator function will then pause execution until the next …
python - How to get a return value from a subroutine run …
Dec 18, 2017 · It seems that you want to give Inputs to a function, run a number of threads simultaneosly, and get the output values. Something like this: import multiprocessing def …
Python Function Return Value - W3Schools
def my_function (x): return 5 * x print(my_function (3)) print(my_function (5)) print(my_function (9))
Python Function Return Values: A Comprehensive Guide
Feb 16, 2025 · A return value is the data that a function sends back to the code that called it. In Python, you use the return keyword to specify what value a function should return.
Python Return Function [With Examples]
Oct 30, 2024 · In this situation, a return statement helps to return the required value of any data type. The return function is a block of code that, when called, returns the result to the caller. …
Python Return Statements Explained: What They Are and Why …
Dec 22, 2024 · New Python coders often get return statements and print statements mixed up. What‘s the difference, and when should you use each? Return sends a value back to the …