[NEWBIE] List issue aka: "Why doesn't this code work?"
Bruce Dykes
bkd at graphnet.com
Fri Feb 8 10:51:55 EST 2002
Okay, here's my function:
def process_numbers(source_list):
for number in range(len(source_list)):
entry = string.split(string.strip(source_list[number]))
print number, len(entry), entry
Now this function is doing *something*...source_list is a list of lines
retrieved via ftp.retrlines(), and this should break each line into it's own
list, and it looks like that's what's being printed out:
['line1', 'header1', 'header2']
['line2', 'datum1', 'datum2']
Notice what's missing? I'm expecting to see:
0 3 ['line1', 'header1', 'header2']
1 3 ['line2', 'datum1', 'datum2']
What the heck am I doing wrong here?
I thought maybe a I had a double nested list, but I tried substituting entry
with entry[0], but that didn't seem to affect anything, and besides, I
should still get number at least, right?
thanks
bkd
More information about the Python-list
mailing list