Why does this not work:
>>> L = [' foo ','bar ']
>>> for i in L:
    i = i.strip()


>>> L
[' foo ', 'bar ']
>>> # note the leading whitespace that has not been removed.

But this does:
>>> L = [i.strip() for i in L]
>>> L
['foo', 'bar']

What other strange behaviour should I expect from for loops?

Thanks,
Colin Caine
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to