To check if number is in range(x,y)
2QdxY4RzWzUUiLuE at potatochowder.com
2QdxY4RzWzUUiLuE at potatochowder.com
Sat Dec 12 13:13:55 EST 2020
On 2020-12-12 at 10:51:00 -0600,
Tim Chase <python.list at tim.thechases.com> wrote:
> If you want numeric-range checks, Python provides the lovely
> double-comparison syntax:
>
> >>> x = 5
> >>> 2 < x < 10
> True
Not just numbers:
>>> 'm' < 'n' < 'o'
True
>>> 'one' < 'one point five' < 'two'
True
Okay, so the second one is a trap, but you get the idea. ;-)
More information about the Python-list
mailing list