Python Forum
why (a and b) different from (b and a)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
why (a and b) different from (b and a)
#5
Look at (True, 2) and (False, False). Here you have exprA and exprB, where exprA=(True, 2) and exprB=(False, False).
It will evaluate True value of each expr from left to right. These are non-empty tuples, so they both are considered to be True. It's a and operator and in the link I shared is explained how it works.

Quote:x and y ==> if x is false, then x, else y

>>> bool((True, 2))
True
>>> bool((False, False))
True
>>> (True, 2) and (False, False)
(False, False)
>>> (False, False) and (True, 2)
(True, 2)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
why (a and b) different from (b and a) - by oloap - Apr-07-2020, 07:24 PM
RE: why (a and b) different from (b and a) - by buran - Apr-10-2020, 09:22 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020