[Tutor] Problem with nested for-in

emmanuel.delaborde emmanuel.delaborde at cimex.com
Thu Jan 29 12:06:57 CET 2009


I have the following snippet :

lines = csv.reader(open("CATEGORY.csv","r"))
lines2 = csv.reader(open("CATEGORYLIST.csv","r"))

old_cats = []
for line in lines:
     stories = []
     for line2 in lines2:
         if line2[1] == line[0]:
     old_cats.append((line[0],line[2], stories))

what happens is that

for the first elt of lines, the nested for in runs fine
but then never seem to run again while the top level loop iterates  
through the rest of lines

consequently stories accumulate nothing...

Can someone explain please ?




This e-mail (and any attachments) is confidential and may contain 
personal views which are not the views of Cimex Media Ltd and 
any affiliated companies, unless specifically stated. It is intended 
for the use of the individual or group to whom it is addressed. If 
you have received it in error, please delete it from your system, 
do not use, copy or disclose the information in any way nor act in 
reliance on it and please notify postmaster at cimex.com

A company registered in England  Wales. Company Number 03765711
Registered Office : The Olde Bakehouse, 156 Watling Street East, Towcester,
Northants NN12 6DB

This email was scanned by Postini, the leading provider in Managed Email Security.

More information about the Tutor mailing list