Tag Archives: : Simplify chained comparison

Pychar yellow wavy line prompt: simplify chained comparison

A super detailed tutorial: springboot integrates mybatis plus>>>

It can simplify the chain comparison

case 1

if a >= 0 and a <= 9:

1

It can be simplified as follows:

if 0 <= a <= 9:

1

It’s like our mathematical expressions. Obviously, this situation only applies to the and situation

case 2

if score > 100 and score < 0:

1

It will be simplified as:

if 100 < score < 0:

1

Obviously, it’s also a fake. It’s not surprising pycharm is not smart enough, but you’ve written the expression wrong

if score > 100 or score < 0: