Return statement
A return statement ends the current function or routine invocation and optionally supplies its result to the caller.
A Pythonic Adventure: From Python basics to a working web app
A return statement exits a function and optionally supplies a result to its caller.
- How it is used
- Uses return statements to pass selected menu items and collected order data from functions to the main program.
- How deep it goes
- Explains function scope and returned values through complete menu and order examples, without exploring return control flow beyond these cases.
- Examples
- Uses a coffee-shop menu that returns a chosen item and an order function that returns a customer dictionary.
- What you can do after
- Build it from scratch by writing functions that return menu selections or collected order data to calling code.
Read how A Pythonic Adventure: From Python basics to a working web app explains return statement →
Get Programming: Learn to code with Python
A statement that terminates a function's execution and optionally supplies a value to its caller.
- How it is used
- Uses `return` to finish a function call and supply a result the caller can use.
- How deep it goes
- Explains early termination, implicit `None`, tuple results, and returning function objects without detailing interpreter internals.
- Examples
- Contrasts printing and returning names, returns a joined string’s length, and unpacks addition and subtraction results.
- What you can do after
- Build it from scratch: write functions whose results can be assigned, printed, or unpacked by a caller.
Read how Get Programming: Learn to code with Python explains return statement →
Python How-To
A return statement terminates a function and optionally supplies a return value to its caller.
- How it is used
- Uses return to define function outputs, stop execution, and pass results through decorators.
- How deep it goes
- Explains implicit, bare, single, and multiple returns, then examines decorator control flow and finally-clause precedence.
- Examples
- Demonstrates None results, greeting and statistics functions, decorator wrappers, and competing returns in try/finally.
- What you can do after
- Apply it via Python to design function outputs, forward decorated results, and predict control flow around finally clauses.
Learn AI-Assisted Python Programming, Second Edition
A return statement ends a function execution and optionally provides a value as the function's output.
- How it is used
- Uses return to pass a function’s answer to its caller during problem decomposition.
- How deep it goes
- Explains return through function outputs, conditional examples, and calls, but does not detail execution internals.
- Examples
- Uses a larger-number function, Python’s max function, and input returning a user’s typed name.
- What you can do after
- Apply it via Python functions to send computed answers back, store results, and test behavior across inputs.
Read how Learn AI-Assisted Python Programming, Second Edition explains return statement →
Modern C
A return statement is a C control-flow statement that ends execution of the current function and optionally supplies a return value.
- How it is used
- Coordinates function calls by ending a function and resuming execution at its caller.
- How deep it goes
- Defines control transfer, typed expressions, multiple returns, and closing-brace behavior, but defers implementation internals.
- Examples
- Uses main returning EXIT_SUCCESS, printf returning to main, and leapyear returning a Boolean expression.
- What you can do after
- Apply it via C syntax to return control and correctly typed values from functions.
Also covered in
- Python Workout: 50 ten-minute exercises
- The Quick Python Book, Fourth Edition
- Modern C, Third Edition
- Julia as a Second Language
- 100 Go Mistakes and How to Avoid Them
- Tiny Python Projects: Learn coding and testing with puzzles and games
- Practical Automation with PowerShell: Effective scripting from the console to the cloud
- The Well-Grounded Rubyist, Fourth Edition
- Python Workout, Second Edition
- Kotlin in Action, 2E
- F# in Action: A Revised Edition of Get Programming with F#
- Write Powerful Rust Macros
What to know first
- loopA loop is a programming-language control-flow construct that repeatedly executes a block of instructions according to an iteration rule or continuation condition.
- functionA function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- callA call is an invocation that requests execution of a function, routine, command, or tool, optionally supplying arguments.
- stringA string is a programming-language value representing textual data as an ordered sequence of characters or encoded units.
Related concepts
- yieldcontrasts with · Yield is a language construct that transfers control or a value from a computation to another context, with behavior that varies by language.
- return valueconfigures · A return value is the result produced by a function, method, or operation and supplied to the code that invoked it.
- functionused by · A function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- Noneproduces · None is Python’s singleton object representing the absence of a value or meaningful result.
- catch blockpart of · A catch block is a language construct that associates a handler with protected code and transfers control to it when an exception or error is raised.
- early terminationproduces · Early termination is deliberately stopping a computation, search, evaluation, or generation before its normal completion when a sufficient result or condition is reached.
Questions about return statement
What is return statement?
A return statement ends the current function or routine invocation and optionally supplies its result to the caller.
Which Manning books explain return statement?
A Pythonic Adventure: From Python basics to a working web app, Get Programming: Learn to code with Python, Python How-To, Learn AI-Assisted Python Programming, Second Edition and Modern C.
What should I know before learning return statement?
Manning books that teach return statement usually introduce loop, function, call and string first.
What is the difference between return statement and yield?
A return statement ends the current function or routine invocation and optionally supplies its result to the caller. Yield is a language construct that transfers control or a value from a computation to another context, with behavior that varies by language.
What is return statement part of?
Return statement is part of catch block. A catch block is a language construct that associates a handler with protected code and transfers control to it when an exception or error is raised.
What is return statement also called?
Return statement is also called function return.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.




