Is there a way to simplify:
if x == 1 and y == 2 and z == 3:
if x == 1 and y == 1 and z == 1:
if x == 1 or y == 2 or z == 3:
if x == 1 or x == 2
is simplified as if x in [1, 2]:
Is there a way to simplify:
if x == 1 and y == 2 and z == 3:
if x == 1 and y == 1 and z == 1:
if x == 1 or y == 2 or z == 3:
if x == 1 or x == 2
is simplified as if x in [1, 2]:
One of your examples is not like the others. The
and
form can easily be simplified:becomes:
However, the
or
form can't be made any neater. It could be rewritten as:but that's hardly "simplified".