January 2019
Beginner
318 pages
8h 23m
English
The return statement is used to exit a function. Refer to the following syntax:
return [expression_list]
This statement may contain an expression where a value has to be returned. If there is no expression, then the function will return a None object, as shown in the following example:
def return_value(a): if a >= 0: return a else: return -aprint(return_value(2))print(return_value(-4))Output:24
Read now
Unlock full access