0

Using 'and' vs a range?

In Python, why does there seem to be a preference of using 'and' statements rather than a range? if (age > 10) and (age < 18): vs if 10 < age < 18:

29th Dec 2020, 1:03 PM
SpasticGinger
SpasticGinger - avatar
2 Answers
+ 3
It'll do the same thing, the second one is just shorter. They both set the same bounderies https://code.sololearn.com/cY4Z79vANdc3/?ref=app
29th Dec 2020, 1:06 PM
Slick
Slick - avatar
+ 3
Second variant is better: if 10 < age < 18:
29th Dec 2020, 2:21 PM
Roma Butaku
Roma Butaku - avatar