Using the Python return Statement Effectively

Howard Francis

The Python return statement is a key component of functions and methods. You can use the return statement to make your functions send Python objects back to the caller code. These objects are known as the function’s return value. You can use them to perform further computation in your programs.

Using the return statement effectively is a core skill if you want to code custom functions that are Pythonic and robust.

In this course, you’ll learn:

  • How to use the Python return statement in your functions
  • How to return single or multiple values from your functions
  • What best practices to observe when using return statements
  • How to structure more advanced return statements

What’s Included:

Downloadable Resources:

Related Learning Paths:

About Howard Francis

Howard is an avid Pythonista and records video courses for Real Python. He has been teaching beginning programming at the college level for over 20 years in C++, Java, C#, and most recently Python.

» More about Howard

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

Participant Comments

Avatar image for alnah

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!

Avatar image for Shubha

Shubha on Oct. 13, 2021

Great Course! Learnt a lot. Thank you.

« Browse All Courses