return is a statement that determines a value the function will move outside of it, before ending the function execution. By default all functions return None, but that's not very useful. The simplest example I can think of is a function that adds two numbers together, and returns the sum. def add(first, second): return first + second total = add(3, 4) print(total) # 7 Answer from Diapolo10 on reddit.com
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-return-statement
Python return statement - GeeksforGeeks
December 20, 2025 - The return statement is used inside a function to send a value back to the place where the function was called. Once return is executed, the function stops running, and any code written after it is ignored.
Discussions

failing to understand the function of return statement in python - Stack Overflow
I am just learning programming, in python.. watching the "programming foundation:fundamental" course from linkedin. although in the beginning it seems easy regarding the function of return More on stackoverflow.com
🌐 stackoverflow.com
[Clean code] Multiple Returns or Single Return at the End in if-else
Hi, I’m currently working on a Python project, and I’ve encountered a situation where I have several if-else statements within a function. I’m trying to determine the best practice for handling return statements in this … More on discuss.python.org
🌐 discuss.python.org
0
July 25, 2024
Recursion with return statements
I’m having a hard time understanding recursive functions with return statements. I’ve read many other explanations and I’m just not getting it. I’m using the example provided in freeCodeCamp’s Python Tutorial for Beginners (with mini-projects) here with extra print statements to help ... More on discuss.python.org
🌐 discuss.python.org
0
October 30, 2024
Asking for help understanding the difference between return and print in function
Hey, everybody. I started functions a few days ago in Python Crash Course. I like this chapter, I understand a function’s purpose, but I’m not understanding the differences between print and return. I also have a question about assigning a variable to a function. More on discuss.python.org
🌐 discuss.python.org
0
March 14, 2024
🌐
Replit
replit.com › home › discover › how to use 'return' in python
How to use 'return' in Python
2 weeks ago - The get_person_details function demonstrates how to send back multiple values. When you use a comma-separated list in the return statement, Python automatically packs these values into a tuple.
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-return-statement
Python return statement | DigitalOcean
August 3, 2022 - The python return statement is used to return values from the function. We can use the return statement in a function only.
🌐
W3Schools
w3schools.com › python › ref_keyword_return.asp
Python return Keyword
Python Examples Python Compiler ... Q&A Python Bootcamp Python Certificate Python Training ... The return keyword is to exit a function and return a value....
🌐
Real Python
realpython.com › python-return-statement
The Python return Statement: Usage and Best Practices – Real Python
June 14, 2024 - The Python return statement is a special statement that you can use inside a function or method to send the function’s result back to the caller. A return statement consists of the return keyword followed by an optional return value.
Find elsewhere
🌐
W3Schools
w3schools.com › python › gloss_python_function_return_value.asp
Python Function Return Value
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... def my_function(x): return 5 * x print(my_function(3)) print(my_function(5)) print(my_function(9)) Try it Yourself »
🌐
Altcademy
altcademy.com › blog › how-to-use-return-in-python
How to use return in Python
September 12, 2023 - So, when we try to print the result, it outputs None. In the realm of Python, a return statement is like a diligent waiter, bringing back the results of a function's hard work back to the table.
🌐
Python documentation
docs.python.org › 3 › tutorial › inputoutput.html
7. Input and Output — Python 3.14.3 documentation
To read a file’s contents, call f.read(size), which reads some quantity of data and returns it as a string (in text mode) or bytes object (in binary mode). size is an optional numeric argument. When size is omitted or negative, the entire contents of the file will be read and returned; it’s your problem if the file is twice as large as your machine’s memory.
🌐
Stack Overflow
stackoverflow.com › questions › 73724950 › failing-to-understand-the-function-of-return-statement-in-python
failing to understand the function of return statement in python - Stack Overflow
Without the outer equality check, the return value is 1 if odd and 0 if even. With the outer equality check, the return value is True if even and False if odd.
🌐
Python.org
discuss.python.org › python help
Recursion with return statements - Python Help - Discussions on Python.org
October 30, 2024 - I’m having a hard time understanding recursive functions with return statements. I’ve read many other explanations and I’m just not getting it. I’m using the example provided in freeCodeCamp’s Python Tutorial for Beginners (with mini-projects) here with extra print statements to help me understand the work flow, but didn’t help much: def add_one(num): print("add_one starting") if (num >= 9): print("num is >= 9") print(num) return num + 1 total = num + 1 p...
🌐
W3Schools
w3schools.com › python › python_functions.asp
Python Functions
Python Examples Python Compiler ... ... A function is a block of code which only runs when it is called. A function can return data as a result....
🌐
DEV Community
dev.to › aswinbarath › functional-programming-in-python-23ff
the return statement in functions - DEV Community
August 29, 2023 - Let me start with a fact: Every function returns a value when called. Well, I don't know about you,... Tagged with python, programming, tutorial, beginners.
🌐
Flexiple
flexiple.com › python › return-in-python
How does return() in Python work? | Flexiple Tutorials | Python - Flexiple
April 22, 2022 - In order to get a value from a function in any programming language, we use the return() statement. Likewise, in Python, the return() statement is used to exit a function and returns a value from a function.
🌐
Python Geeks
pythongeeks.org › python geeks › learn python › the python return statement : usage and best practices
The Python Return Statement : Usage and Best Practices - Python Geeks
October 13, 2023 - The return statement in Python is used to exit a function and return a value to the caller. It allows you to pass back a specific result or data from a function, enabling you to utilize the output for further computation or processing.
🌐
Python.org
discuss.python.org › python help
Asking for help understanding the difference between return and print in function - Python Help - Discussions on Python.org
March 14, 2024 - Hey, everybody. I started functions a few days ago in Python Crash Course. I like this chapter, I understand a function’s purpose, but I’m not understanding the differences between print and return. I also have a questio…
🌐
Nanyang Technological University
libguides.ntu.edu.sg › python › functionreturn
2.3 Functions with Return Values - Python for Basic Data Analysis - LibGuides at Nanyang Technological University
Start your data science journey with Python. Learn practical Python programming skills for basic data manipulation and analysis. ... Using return, you can write a function that returns a value.
🌐
Python documentation
docs.python.org › 3 › library › functions.html
Built-in Functions — Python 3.14.3 documentation
2 days ago - As repr(), return a string containing a printable representation of an object, but escape the non-ASCII characters in the string returned by repr() using \x, \u, or \U escapes. This generates a string similar to that returned by repr() in Python 2.
🌐
All About AI-ML
indhumathychelliah.com › 2020 › 09 › 04 › everything-you-ever-wanted-to-know-about-python-return-statements
Everything You Ever Wanted to Know About Python Return Statements – All About AI-ML
January 2, 2022 - “When return passes control out of a try statement with a finally clause, that finally clause is executed before really leaving the function.” — Python documentation