[Fixed] python – How do I check if a list is empty?

Question (Issue)

For example, if passed the following:

a = []

How do I check to see if a is empty?

Now we will see solution for issue: How do I check if a list is empty?


Answer (Solution)

if not a:
    print("List is empty")

Using the implicit booleanness of the empty list is quite pythonic.

This question is answered By – Patrick

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0