Language Syntax
Return — Python syntax
Exit the current function and deliver a value to its caller. Omitting the expression returns None; a finally suite still executes before control leaves. In a synchronous generator, the value is carried by StopIteration. An asynchronous generator cannot return a nonempty value. A return from finally can mask a pending exception or return value; prefer cleanup only.
Formal Syntax & Structure
python syntaxpython
returnreturn expressionParameters & Attributes
| Name | Type | Description |
|---|---|---|
| expression | expression | Optional function return value. |
Working Example
Example Snippetpython
def total(a,b): return a+bprint(total(2,4))