Line indexing in Python
seafoid
fitzpadj at tcd.ie
Fri Dec 18 11:27:56 EST 2009
Thanks for that Richard and Steve.
I have another question.
fname = raw_input('Please enter the name of the file: ')
# create file objects
blah = open(fname, 'r')
a = open('rubbish', 'w')
for line in blah:
if line.startswith("0"):
a.write(line)
elif line.endswith("0"):
lists_a = line.strip().split()
print lists_a
elif line.startswith("0"):
lists_b = line.strip().split()
print lists_b
Essentially, I wish to take input from a file and based on the location of
zero, assign lines to lists.
Any suggestions?
Seafoid.
--
View this message in context: http://old.nabble.com/Line-indexing-in-Python-tp26845253p26845949.html
Sent from the Python - python-list mailing list archive at Nabble.com.
More information about the Python-list
mailing list