Functions · warm-up
Clamp
Write clamp(x, low, high): return low if x is below it, high if x is above it, and x otherwise.
- right answers
- arguments left as they should be
Run adds print(clamp(42, 0, 10)) after your code, to try it.
Stuck on the idea rather than the code? The Functions lesson walks through it.