Intermediate
Document a function with doctest examples
clamp(value, low, high) returns value limited to the range from low to high. Its implementation is done.
Write the docstring examples: at least three >>> examples with the expected output underneath. Include a value inside the range, one below low, and one above high. Write each expected output exactly as Python would print it: the number 5 prints as 5, with no quotes.
The runner code at the bottom runs your examples and prints how many were tried and how many failed. All of them must pass.
What Check tests
- At least 3 examples were run
- No example fails
- The docstring has at least 3
>>>lines clampbehaves correctly
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.