Python - Functions Without returns

Introduction

In Python functions, return statements are optional.

When a function doesn't return a value explicitly, the function exits when control falls off the end of the function body.

Technically, all functions return a value; if you don't provide a return statement, your function returns the None object automatically:

Demo

def proc(x): 
  print(x)                 # No return is a None return 
# from   w w w .  ja v a  2 s . c om
x = proc('testing 123...') 
print(x)

Result

Related Topic