Question #124

What is the output of this code snippet?
bool([[]])

The __bool__() method of lists returns True when the list is not empty, and False when the list is empty. Here, the outer list is not empty has it contains another (empty) list. As such, bool([[]]) returns True . (tutorialspoint.com/How-to-check-if-a-list-is-empty-in-Python)


Comment on Disqus:

Comment on Twitter:

Question difficulty: 🔵🔵🔵🔵🔵


Similar questions: