TransWikia.com

Boolean expression ( 0 or None and False)

Stack Overflow Asked by UNA on September 7, 2020

Question: 0 or None and False

why it give me None as answer? I totally don’t understand

I thought None and False should be False because none of them are True, but my python shell tell me it’s None. Why’s that?

One Answer

You may find this post helpful:

External Discussion on SoloLearn

Example:

None and False
>>> None

False and None
>>> False

0 or None
>>> None

None or 0
>>> 0

It has to do with the behavior of 'and', which checks the first argument before the second (called short-circuit evaluation).

Another resource about general boolean logic in Python.

Answered by funyuns on September 7, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP