why?
Aloysio Paiva de Figueiredo
aloysio at impa.br
Mon Dec 2 17:48:27 EST 2002
> Hi!
>
> Why does this happen:
>
> >>> doing = ['a','b','c']
> >>> doing[1] = ('b','c')
> >>> doing[1][0]
> 'b'
> >>> doing[1][0] = 'i'
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> TypeError: object doesn't support item assignment
> >>>
>
> Why can't I change that value from 'b' to 'i' ? Why?
>
Tuples are immutable. Try changing
>>> doing[1] = ('b','c')
for
>>> doing[1] = ['b','c']
and it will work
[]'s
-Aloysio
More information about the Python-list
mailing list