[Tutor] Writing processed text to another file(beginner)
Mayo Adams
mayoadams at gmail.com
Sat Nov 5 20:04:50 CET 2011
Code to build a list z to contain all the first words in each line of a
text file:
z=[]
f=open('C:/atextfile.txt')
for aLine in f:
str=aLine
a=str.split()
z.append(a)
I would like to work further with the list z once the file has been
stripped, and the list is complete but am so clueless about Python and its
curlybracelessness that I don't know when the for loop terminates.
Obviously I don't want to write to the file after every line is read.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111105/f81f725e/attachment.html>
More information about the Tutor
mailing list