simple problem with lists I am just forgetting




Lets say we have this list:

funlist = ['a', 'b', 'c']

and lets say I do this:

if funlist[4]:
print funlist[4]

I will get the exception "list index out of range"

How can I test if the list item is empty without getting that exception?
--
View this message in context: http://www.nabble.com/simple-problem-with-lists-I-am-just-forgetting-tp18762181p18762181.html
Sent from the Python - python-list mailing list archive at Nabble.com.

.



Relevant Pages

  • Re: Try Finally...
    ... writing for exceptions is IMHO to make every routine survive an exception, ... values, etc., to the raised exception. ... Test the error handling mechanism by throwing exceptions at the deepest ... ...because info like "List index out of bounds " is the most frustrating ...
    (comp.lang.pascal.delphi.misc)
  • Re: simple problem with lists I am just forgetting
    ... How can I test if the list item is empty without getting that exception? ... Try using a slice. ... Slices are ignorant of list index validity. ... Voila! ...
    (comp.lang.python)
  • Re: Unusual Exception Behaviour
    ... traceback info forward to log file." ... This will obviously capture every exception happening in the mainfunction. ... list index out of range ...
    (comp.lang.python)
  • Re: SharePoint Services Authentication problem (after SharePoint Server removal)
    ... Exception Details: System.UnauthorizedAccessException: Access to the path ... granting access rights to the resource to the ASP.NET request identity. ... System.IO.StreamWriter.CreateFile(String path, Boolean append) +55 ... context) +98 ...
    (microsoft.public.sharepoint.portalserver)
  • Re: Exchange OWA 2003 "Server Error in /OWAAdmin Application"
    ... I can right click elsewhere within the outlook window but not on the ... Exception Details: System.UnauthorizedAccessException: Access to the path ... granting access rights to the resource to the ASP.NET request identity. ... context) +85 ...
    (microsoft.public.exchange.admin)