Click here to Skip to main content
15,867,765 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Python
ef clip(lo, x, hi):
    '''
    Takes in three numbers and returns a value based on the value of x.
    Returns:
     - lo, when x < lo
     - hi, when x > hi
     - x, otherwise
    '''


My added code

Python
ef clip(lo, x, hi):
    '''
    Takes in three numbers and returns a value based on the value of x.
    Returns:
     - lo, when x < lo
     - hi, when x > hi
     - x, otherwise
    '''
    if min(x, lo, hi) == x:
        return lo
    elif max(x, lo, hi) == x:
        return hi
    else:
        return x
Posted
Updated 19-Feb-13 12:12pm
v3
Comments
Sergey Alexandrovich Kryukov 19-Feb-13 18:06pm    
I cannot see: do you observer indentation?
—SA
Valmach 19-Feb-13 22:15pm    
thanks..
Graham Breach 19-Feb-13 18:14pm    
I've added PRE tags around your code to show the indentation. Did you miss off the "d" from "def" when you pasted, or is that the problem?
Valmach 19-Feb-13 22:15pm    
thank you
TRK3 19-Feb-13 18:59pm    
So what exactly is the problem?

Is the python iterpreter complaining? If so, what is the message?

Or are you getting unexpected results? Is so, what is your input, and output?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900