This is a very basic question because I am a new user of SAGE with a background mostly in Java and C++. But in the following session:
sage: var('A')
A
sage: var('B')
B
sage: for item in alist:
item = B
print item
....:
B
sage: for item in alist:
print item
....:
A
I am not sure why the value of the item in the list is printed as 'A' instead of 'B'. During the previous loop it seems like it assigned the value 'B' and printed out that the item was 'B. This may be an issue of the line 'item = B' returning a transient copy of the item, instead of a reference to the item. Can someone explain what is going on in programming language terms and tell me how to fix this so that the last line would print 'B'?