0

can i use the second if sentence in python with the same calculation?

val1 = 1
val2 = 2
val3 = 3

if val1 < val2 and val2< val3:
   print ('Hello world')

if val1 < val2 < val3:
   print("World hello")

Because I found a similar question in the C section with the answer:

The > operator is left-associative, so A > B > C is parsed as (A > B) > C. A > B evaluates to 0 or 1, so you're basically comparing 0 > C or 1 > C.

0 Answers0