Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries


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

Example:

In the below example, return keyword is used to return the square of a given number.

def area_square(a):
  area = a * a
  print("Area of the square is:")
  return area

print(area_square(3))

The output of the above code will be:

Area of the square is:
9

Any statement after return statement is ignored by the program.

Example:

In the below example, the print statement after return statement is ignored when executed.

def area_square(a):
  area = a * a
  return area
  print("Area of the square is:")

print(area_square(3))

The output of the above code will be:

9

❮ Python Keywords