Check if a given value is out of certain range

Michiel Overtoom motoom at xs4all.nl
Mon Oct 5 04:18:29 EDT 2015


Why not use a function?


    if outside(x, 0, 10):
        print("x has wrong value")
    else:
        print("x has good value")


where 'outside' is defined as:

    def outside(value, lowerbound, upperbound):
        return value < lowerbound or value > upperbound  

Greetings,




More information about the Python-list mailing list