How to add a current string into an already existing list

Dave Angel davea at davea.name
Tue Nov 5 06:00:33 EST 2013


On Tue, 05 Nov 2013 11:34:53 +0200, Nick the Gr33k 
<nikos.gr33k at gmail.com> wrote:
> I see, but because of the traceback not being to express it more 
easily 
> i was under the impression that data wasn't what i expected it to 
be.

Exactly. So why didn't you act on that impression?

Your error message told you that data was a method, and that a method 
is not iterable. The previous line is where you assigned it.

Try debugging this:

infile = open("myfile.txt")
data = infile.readlines
 for line in data:
    print(line)

Not on a server. On your own machine.

-- 
DaveA




More information about the Python-list mailing list