Dave Angel a écrit :
(snip)

As Chris says, you're modifying the list while you're iterating through it, and that's undefined behavior. Why not do the following?

mylist = line.strip().split(' ')
mylist = [item for item in mylist if item]

Mmmm... because the second line is plain useless when calling str.split() without a delimiter ?-)

>> mylist = line.strip().split()

will already do the RightThing(tm).

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to