Skip to content
dreamcode
dreamcode
Back to map
Return values · Lesson 16 of 44
+15 XP on finish
PYTHON BASICS

Sending data back

A function can calculate a result and send it back to the caller using the return keyword. Once a function returns, it exits immediately. If you do not write return, the function returns None.

How it reads
return x * 2 calculates the value and immediately finishes the function
result = double(10) captures the returned value (20) and stores it in result
Cloud tip: Do not confuse print() and return. print() displays text to the screen, while return passes data back to your code so you can use it in other calculations.
main.py
PYTHON
real Python, runs in your browser
CONSOLE
- run your code to see output -