What way is the best to check an empty list?

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Wed Mar 25 15:52:52 CET 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