[Tutor] Open a text file, read and print pattern matching
ALAN GAULD
alan.gauld at btinternet.com
Sun Jan 9 15:34:22 CET 2011
> thanks this solve the error but running the code produces another error ie
>index out of range.
> if line[3] == pattern:
> IndexError: list index out of range
So you need to check that there are at least 4 elements in the line before
trying to access it. Or else catch the exception (see my other post about
unpacking the data)
HTH,
Alan G.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110109/53140c89/attachment.html>
More information about the Tutor
mailing list