Click here to Skip to main content
11,642,855 members (70,224 online)
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 11:46am
Valmach141
Edited 19-Feb-13 12:12pm
(no name)23.3K
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 DamithSL 328
1 OriginalGriff 280
2 Sergey Alexandrovich Kryukov 270
3 Afzaal Ahmad Zeeshan 195
4 jyo.net 190
0 DamithSL 541
1 OriginalGriff 495
2 Mika Wendelius 469
3 Sergey Alexandrovich Kryukov 330
4 Afzaal Ahmad Zeeshan 324


Advertise | Privacy | Mobile
Web01 | 2.8.150731.1 | Last Updated 19 Feb 2013
Copyright © CodeProject, 1999-2015
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