BlaztOne
BlaztOne

Reputation: 180

Why does this ignore my variable for no reason?

Str1, Str2 = "aardvark", "zebra" print(Str1 < Str2 and Str1 .. Str2 or Str2 .. Str1) The Output is : aardvarkzebra When i remove Str1, the output was still the same Str1, Str2 = "aardvark", "zebra" print(Str1 < Str2 and Str1 .. Str2 or Str2) The Question is: Where does my Str1 go?

Upvotes: 0

Views: 39

Answers (1)

luther
luther

Reputation: 5564

In both examples, Str1 < Str2 is true, so the same expression (Str1 .. Str2) gets printed both times. The right operand of or is ignored because its left operand is true.

Upvotes: 1

Related Questions