I get some user input and if they pick a value outside of a given interval I want to set the value to the edge value. I can do it like this:
if input > upper_limit:
input = upper_limit
elif input < lower_limit:
input = lower_limit
It feels like there should be a nicer way of doing this but I can't figure out how. Do you have any suggestions?