Mega Code Archive

 
Categories / Python Tutorial / Data Type
 

Python accepted almost anything in a boolean context

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.