[portland] List Index Out Of Range [RESOLVED]

Rich Shepard rshepard at appl-ecosys.com
Wed Jul 18 21:03:22 CEST 2012


On Wed, 18 Jul 2012, Jonathan Karon wrote:

>    if not len(line.strip()): continue # ignore blank lines

   Ah, that does make sense. Didn't think of that.

> " f.readline() reads a single line from the file; a newline character (\n)
> is left at the end of the string "
>
> The last element of your chems list will still contain that trailing
> linefeed. Try this when initially loading the chems list:
>
> chems = [c.strip() for c in infile.readline().split(',')]

   That did the trick.

   Thank you both, Jonathan and Ethan, for the lessons.

Much appreciated,

Rich




More information about the Portland mailing list