Python return Keyword

Example

Exit the function and return the sum:

def myfunction():
  return 5+5
print(myfunction())

Run an instance

Definition and Usage

The return keyword is used to exit the function and return a value.

More Examples

Example

The statements after the return line will not be executed:

def myfunction():
  return 5+5
  print("Hello, World!")
print(myfunction())

Run an instance

related pages

Use the keyword def Define a function.

Please visit our Python Functions Tutorial Learn more about functions in Chinese.