Python return Keyword

❮ Python Keywords


Example

Exit a function and return the sum:

def myfunction():
  return 3+3

print(myfunction())
Try it Yourself »

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())
Try it Yourself »

Related Pages

Define a function using the keyword def.

Read more about functions in our Python Functions Tutorial.

❮ Python Keywords

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.