Ray Vega Ray Vega - 2 months ago 25
Python Question

Best way to check if a list, tuple or dict is empty

For example, if passed the following:

a = []
(or
a={}
or
a=()
)

How do I check to see if
a
is empty?

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

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