I have a list that I want to change in a for loop. It changes in the loop but the changes are not persistant outside of the loop.
I thought lists were mutuable objects so I am a bit confused.

Sample Code....
#!/usr/bin/env python
""" Testing lists """

mylist = [ 'One    ', '   two', '   three   ' ]
print mylist
for element in mylist:
    element = element.strip()
    print "<>" + element + "<>"
print mylist


Sample Output....
['One    ', '   two', '   three   ']
<>One<>
<>two<>
<>three<>
['One    ', '   two', '   three   ']

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to