Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Python2.7
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
 
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 19-Feb-13 12:46pm
Valmach141
Edited 19-Feb-13 13:12pm
(no name)22.5K
v3
Comments
Sergey Alexandrovich Kryukov at 19-Feb-13 18:06pm
   
I cannot see: do you observer indentation?
—SA
Valmach at 19-Feb-13 22:15pm
   
thanks..
Graham Breach at 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 at 19-Feb-13 22:15pm
   
thank you
TRK3 at 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?
Valmach at 19-Feb-13 22:15pm
   
Thanks..

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

  Print Answers RSS
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,192
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 19 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100