Predict Multiple Return Values
Predict Output Medium
Question
What does this code print?
Code
def min_max(nums):
return min(nums), max(nums)
lo, hi = min_max([4, 2, 8, 1])
print(lo, hi)
Hint
The function returns a tuple that gets unpacked.
Explanation
min_max returns (min, max) = (1, 8). The tuple is unpacked into lo=1, hi=8. print(lo, hi) outputs: 1 8
Related Resources
Related Lessons
- Python Functions
Multiple return values.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.