Checking if list is empty

suggest change

The emptiness of a list is associated to the boolean False, so you don’t have to check len(lst) == 0, but just lst or not lst

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