simple problem with lists I am just forgetting

bearophileHUGS at bearophileHUGS at
Thu Jul 31 21:59:02 CEST 2008

> How can I test if the list item is empty without getting that exception?

In Python such list cell isn't empty, it's absent. So you can use
len(somelist) to see how much long the list is before accessing its
items. Often you can iterate on the list with a for, so you don't need
to care of the len().


More information about the Python-list mailing list