0

I get the same results for the condition:

a<b and a<c 

and the condition:

a<b and c 

a, b, c are variables of the type float

I never see that before. I prefer the first writing way. I only forgot a< in my code. But it is working.

Is it possible in python to short the condition like that? Is there a special name for shortcuts like that above?

Thank you for an answer in advance! Yours JoeJoe

Alexander
  • 59,041
  • 12
  • 98
  • 151
JoeJoe
  • 1
  • 1
  • 1
    What are the values of `a`, `b` and `c`? – bereal Aug 24 '22 at 18:12
  • 2
    It's not, but it happens to work for some values of `a`, `b` and `c` that you're trying it with. It worked because non-0 floats are truthy. Consider a trivial counter example: `-1 < 1 and 0` (`a = -1; b = 1; c = 0`) – Alexander Aug 24 '22 at 18:13
  • 1
    They are different and this is a common pitfall: https://stackoverflow.com/questions/39983695/what-is-truthy-and-falsy-how-is-it-different-from-true-and-false – wkl Aug 24 '22 at 18:13

0 Answers0