[Solved] check if value inside the range [closed]


This is a foolproof way of doing it although it is not the most efficient:

from re import findall as f

r="5"

level=3

a = f(r'(\d+)?-?(\d+)', r)[0]

try:
    print int(a[0]) <= level <= int(a[1])
except (IndexError, ValueError):
    print 0 <= level <= int(a[1])

3

solved check if value inside the range [closed]