Using the Python return Statement Effectively (Summary)
The Python return
statement allows you to send any Python object from your custom functions back to the caller code. This statement is a fundamental part of any Python function or method. If you master how to use it, then you’ll be ready to code robust functions.
In this course, you’ve learned how to:
- Effectively use the Python
return
statement in your functions - Return single or multiple values from your functions to the caller code
- Apply best practices when using the
return
statement
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.
00:00 Let’s review what you’ve learned in this course.
00:04
You’ve seen how the Python return
statement is used in a function to return any Python object back to where the function was called, and that the Python return
statement is a key component of functions and methods.
00:18
In this course, you learned how to write a Python return
statement, how you can return single and multiple values with a return
statement, and you learned some best practices for using the return
statement.
00:32
You were also introduced to some more advanced ways to use the return
statement in Python, such as closure factory functions and function decorators, among others.
00:43
I hope you enjoyed this course on using the Python return
statement, and I hope to see you in another course here at Real Python soon.
aniketbarphe on Dec. 26, 2021
Thank You!
alnah on Sept. 24, 2023
This course was outstanding! It was well-structured, clear, and practical. I especially appreciated the sections on closures, decorators/wrappers, and factories. It provides a good introduction to understanding generators as well. The best practices part was very great! Please do that for functions in Python as well!
Become a Member to join the conversation.
Shubha on Oct. 13, 2021
Great Course! Learnt a lot. Thank you.