python – Determine Whether Integer Is Between Two Other Integers?

python – Determine Whether Integer Is Between Two Other Integers?

if 10000 <= number <= 30000:
    pass

For details, see the docs.

>>> r = range(1, 4)
>>> 1 in r
True
>>> 2 in r
True
>>> 3 in r
True
>>> 4 in r
False
>>> 5 in r
False
>>> 0 in r
False

python – Determine Whether Integer Is Between Two Other Integers?

Your operator is incorrect. Should be if number >= 10000 and number <= 30000:. Additionally, Python has a shorthand for this sort of thing, if 10000 <= number <= 30000:.

Leave a Reply

Your email address will not be published.