[EMAIL PROTECTED] wrote in
news:[EMAIL PROTECTED]: 

> But this gives me "IndexError: list out of range

You are making the list shorter as you are iterating. By the time your 
index is at the end of the original list, it isn't that long any more. 
Creating a new list and appending the elements you want to keep avoids 
the problem. Or you can just use a list comprehension(untested):

returned_lines=[line for line in open("lines.txt", 'rb') 
                    if line != ""]

or just

returned_lines=[line for line in open("lines.txt") if line]

max


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

Reply via email to