Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Well, you can do the following, but I'm not sure if this is what you want:

sage: seq = (1,2,3,4)
sage: seq[0]=2
---------------------------------------------------------------------------
TypeError: 'tuple' object does not support item assignment
sage: seq2 = list(seq)
sage: seq2[0]=2
sage: seq2
[2, 2, 3, 4]

However, my guess is that you want to make seq above a mutable object. I don't think this is possible - you can try to search the Python site to see if you can find an exception to this. In general, if you want to make something mutable, the type has to start as mutable, as far as I know, and Python is strongly typed (i.e. you can't change the type of an object once it's created).