I have a condition if i <" 15 or 19<“i <” 23

But I would like to use two parameter in the condition.

Which is like this. But it’s not working.

if i <'5 and j <'17) or (19<'i<'23 and j<'14):

Ps: <’ is less than

I have a condition if i <" 15 or 19<“i <” 23

But I would like to use two parameter in the condition.

Which is like this. But it’s not working.

if i <'5 and j <'17) or (19<'i<'23 and j<'14):

Ps: <’ is less than

Hi Liu.

What is the difference between <" and <’ ? They both mean “less than”? If that’s so, then you just forgot to put one of parentheses at the beginning of your expression:

```
if (i < 5 and j < 17) or (19 < i < 23 and j < 14):
print "that's it"
else:
print "no it ain't"
```

I would also recommend staying away from equations that look like

19 < i < 23

And instead write this out as

(19 < i and i < 23)

I haven’t tried with python, but a value of 50 for i may give you an unexpected result if you use the first form. This is because as languages evaluate an expresseion from left to right, it could be done so that first the computer tests

19 < i “where i is the value 50"

This would return True

Then the computer would evaluate

"result of previous evaluation” < 23

That result is True which is typically the value of 1 in many languages. Since 1 is less than 23, you would get a result of True which is not what you would expect. I’m not sure if this is exactly how python evaluates that expression, but it is a generally good idea to break tests down into atomic tests so there is no possibility of confusion.