What way is the best to check an empty list?

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Wed Mar 25 10:52:52 EDT 2009


srinivasan srinivas:
> For ex: to check list 'A' is empty or not..

Empty collections are "false":

if somelist:
    ... # somelist isn't empty
else:
    ... # somelist is empty

Bye,
bearophile



More information about the Python-list mailing list