return
KeywordPython 2.0+Beginner
Exits a function and optionally sends a value back to the caller
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
Learn by Difficulty
Quick Example
python
def add(a, b): return a + b result = add(3, 4) print(result) def is_even(n): return n % 2 == 0 print(is_even(4)) print(is_even(7))
return sends a value back to the caller and exits the function immediately. Without return, a function returns None.
Try in PlaygroundTags
languagesyntaxcorefunctionoutput