DEV Community

Discussion on: How to check if a list is empty in python?

Collapse
 
nisegami profile image
Arshad Hosein

One thing to note is that method 1 and 2 will also exhibit the same behavior if the list is None. However, this will raise an Exception with method 3. This is an important distinction and how you want to handle or not handle None should inform which you use (or what other checks you need). As for method 2 itself, it's just a more verbose method 1 and I wouldn't ever really recommend it be used personally.