Click here to Skip to main content
12,396,149 members (62,466 online)
Rate this:
 
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
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?
Valmach 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
Top Experts
Last 24hrsThis month


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