💡 What You'll Learn
return sends a value back from a function. Unlike print() which shows output, return lets you use the result in your code. Functions can only return one value.
return_demo.py
1def add(a, b):
2 return a + b
3result = add(3, 4)
4print(result) # 7
📺 Try the calculator!
+
Result appears here!
🎯 Your Challenges
1Multiply & Return
Create a function that multiplies and returns the result
2Use the Result
Store the return value and use it again
3Chaining Functions
Use the return value of one function as input to another
📚 What You Learned
return valuesends a value back- Store the return value:
result = func() - return ends the function immediately
- Functions without return give
None