[Tutor] Re: References in loops

2005-02-12 Thread Brian Beck
Andrei wrote: Numbers are immutable, so the element 1 can't change into a 2 inside the list. If 1 was not immutable, e.g. a list you could modify it and then it would be "updated" in the original list too. It doesn't have anything to do with mutability, only the scope of i. Consider a list of li

[Tutor] Re: References in loops

2005-02-12 Thread Andrei
Matt Dimmic wrote: In Python, one bug that often bites me is this: (example A) aList = [1,2,3] for i in aList: i += 1 print aList --> [1,2,3] Numbers are immutable, so the element 1 can't change into a 2 inside the list. If 1 was not immutable, e.g. a list you could modify it and then it woul