On 12/19/2009 3:27 AM, seafoid wrote:

Thanks for that Richard and Steve.

I have another question.

What's the 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

The following block is a dead code; the block will never be executed since if line.startswith("0") is true, the control will fall to the a.write(line) block and this block is skipped.
     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.


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

Reply via email to