I found a thread on this but am not having any luck getting it working.
min = 9
max = 10
a = ['8','9','10','11']
for x in a:
if max >= x > min:
print 'one'
else:
d = (max >= x > min)
print d, x
if (x > min >= max):
#if (min < x >= max):
print x
else:
print x, ' is equal to or greater than', max
Outputs:
False 8
8 is equal to or greater than 10
False 9
9 is equal to or greater than 10
False 10
10 is equal to or greater than 10
False 11
11 is equal to or greater than 10
this thread working code? indicates syntax needs to be:
if 10000 <= number <= 30000:
pass
I've tried every combination of signs I can think of, and the returns are always True or False for all, which is wrong.
I've also tried this (much longer) code:
min = 9
max = 10
a = ['8','9','10','11']
for x in a:
print 'X is:', x
if int(x) == max:
print 'max found:', x
elif int(x) < max:
if int(x) > min:
print 'min:', x
elif int(x) < min:
print 'under range', x
else:
print 'out of range', x
with output also unexpected, since I expect to catch all cases:
X is: 8
X is: 9
X is: 10
max found: 10
X is: 11
out of range 11
Ugh! How can I check all items 'properly' and return under, at, over my min, max?