How to check if an item exist in a nested list

Arash Arfaee erexsha at gmail.com
Thu Jul 19 23:43:13 CEST 2007


Hi All,

Is there any way to check if an item in specific location in a multiple
dimension nested exist?  For example something like:

if M_list[line][row][d] exist:
  do_something_0
else:
  do_something_1

One way is to check the length of each dimension. Does any body know a
simpler way? is there any way to check if "IndexError: list index out of
range" happened or going to happen and stop program from terminating?

Thanks
Arash
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070719/db12026c/attachment.html>


More information about the Python-list mailing list