Python return Keyword
Example
Exit a function and return the sum:
def myfunction():
return 3+3
print(myfunction())
Run example »
Definition and Usage
The return
keyword is to exit a function and
return a value.
More Examples
Example
Statements after the return line will not be executed:
def myfunction():
return 3+3
print("Hello, World!")
print(myfunction())
Run example »
Related Pages
Define a function using the keyword
def
.
Read more about functions in our Python Functions Tutorial.