-1

I wrote a code like this:

print(1 and 9) #print 9

I thought that 1 evaluates to True and 9 evaluates to True as well. So True and True should be 1 right? But in here it is 9.

cuong.pq
  • 137
  • 1
  • 1
  • 4
  • 1
    Does this answer your question? [How do "and" and "or" act with non-boolean values?](https://stackoverflow.com/questions/47007680/how-do-and-and-or-act-with-non-boolean-values) – rdas Jun 24 '20 at 19:42

1 Answers1

0

From the docs:

The expression "x and y" first evaluates *x*; if *x* is false, its
value is returned; otherwise, *y* is evaluated and the resulting value
is returned.

You can see it by help function too:

help("and")
Vicrobot
  • 3,795
  • 1
  • 17
  • 31