Check if a given value is out of certain range
rosuav at gmail.com
Tue Sep 29 10:01:05 CEST 2015
On Tue, Sep 29, 2015 at 2:46 PM, Laxmikant Chitare
<laxmikant.general at gmail.com> wrote:
> I know there is an elegant way to check if a given value is within certain
> Example - To check if x is between zero and ten, I can do 0 < x 10.
> Is there any similar elegant way to check if a value is out of certain
> Example - To check if x is either less than zero or greater than ten?
> Right now I am using x < 0 or x > 10.
You can simply negate the condition:
not 0 <= x <= 10
More information about the Python-list