checking if a list is empty

Jabba Laci jabba.laci at gmail.com
Fri May 6 02:36:26 EDT 2011


Hi,

If I want to check if a list is empty, which is the more pythonic way?

li = []

(1) if len(li) == 0:
...
or
(2) if not li:
...

Thanks,

Laszlo



More information about the Python-list mailing list