Checking if list is empty

suggest change

An empty list is falsy (bool([]) is False, but [] == False is not true), so you can test if not lst instead of if len(lst) == 0.

lst = []
if not lst:
    print("list is empty")

# Output: list is empty

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents