Boolean Data Type Examples
Boolean Data Type Example
When Boolean Returns False
- For
False
:bool(False)
- For Zero:
bool(0)
- For Empty String:
bool('')
- For Empty List:
bool([])
- For Empty Tuple:
bool(())
- For Empty Dictionary:
bool({})
- For None:
bool(None)
When Boolean Returns True
- For greater than Zero:
bool(1)
- For at least one String:
bool('a')
- For at least one item in List:
bool(['a'])
- For at least one item in Tuple:
bool(('a'))
- For at least one item in Dictionary:
bool({'a': 'A'})