The return statement ends a function immediately and sends a value back to the caller. The call expression then evaluates to that value, so you can assign it, print it or use it in a larger expression: total = add(2, 3) or print(add(2, 3) * 10). Any code after an executed return in the same function is skipped, and even a return inside a loop ends the whole function, not just the loop. A function can contain several return statements, for example one in each branch of an if, but only one of them runs per call.
Keep reading for free
Create a free StudyToCert account to read the rest of this lesson: 7 more sections, 6 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.