David,

You are processing a text file. It is your job to treat it as a file comprised of lists. I think what you are saying is that each line in the text file is a list. In that case

for line in fileobject:
   listline = list(line)

Now, listline is a list of the text items in line.

Hope this helps.

Robert Berman

David Holland wrote:
Hi,

I am trying to create a program where I open a file full of lists and process them.
However when the program does not recognize the lists as lists.
Here is the relevant code :-
def open_filedef():
    text_file =open ("voteinp.txt","r")
    lines = text_file.readlines()
for line in lines:
        print line
        print line[0]
text_file.close()

And an example of the type of text :-

['a','b','c']
['e','d','f']

Any ideas?


Thanks in advance


David Holland


------------------------------------------------------------------------

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to