What is the bool() Method in Python?
bool() is a built-in function of Python programming language. It is used to convert any other data type value (string, integer, float, etc) into a boolean data type.
boolean data type can store only 2 values: True and False.
False Values: 0, NULL, empty lists, tuples, dictionaries, etc.
True Values: All other values will return true.
bool() in Python
Python bool() function is used to return or convert a value to a Boolean value i.e., True or False, using the standard truth testing procedure.
Example
Python3
x = bool ( 1 ) print (x) y = bool () print (y) |
Output
True False