Python - Functions Without returns


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:


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...') 


Related Topic