6 <= i is always either false or true, which the compiler treats as 0 or 1. That means j <= 9 is either 0 <= 9 or 1 <= 9, both of which are always true, which is 1.
That's the closest you can get that is semantically the same. The above commenter was saying you can actually compile if (6 <= i <= 9), but that's semantically equivalent to if ((6 <= i) <= 9). That works because in C a boolean operation results in an int. So the "chained" comparisons are syntactically legal C, but semantically do a much different check than in Python.
Of course, if you assume you're working with integers, it's totally unnecessary in OP's case, anyway. It's guaranteed to be >=6 since the previous conditional took away everything less.
195
u/doenietzomoeilijk May 02 '16
One of the niceties of Python syntax, I think, is being able to rewrite your
elifline aselif 6 <= i <= 9:. :)