Python boolean Values

The builtin boolean values are True and False.

>>> x = TRUE
>>> if (x): "good";
...
'good'
Function bool() can be used to test a boolean value:
>>> bool(True)
True
>>> bool(False)
False
Other False values include: None, 0, [], (), "", ''. Similarly, 1, not empty list, string, and not empty tuplets can be treated as True.
>>> bool(True)
True
>>> bool(False)
False
>>> bool(None)
False
>>> bool(0)
False
>>> bool("")
False
>>> bool("good")
True
>>> bool([1,2])
True










endmemo.com © 2024  | Terms of Use | Privacy | Home