Python accepted almost anything in a boolean context : Boolean « Data Type « Python Tutorial






0 is false; all other numbers are true.

An empty string ("") is false, all other strings are true.

An empty list ([]) is false; all other lists are true.

An empty tuple (()) is false; all other tuples are true.

An empty dictionary ({}) is false; all other dictionaries are true.








2.1.Boolean
2.1.1.true and false value
2.1.2.Python accepted almost anything in a boolean context
2.1.3.The following are defined as having false values in Python
2.1.4.using Booleans numerically