'str' object does not support item assignment

Andrea Crotti andrea.crotti.0 at gmail.com
Sun Sep 23 14:48:49 EDT 2012


On 09/23/2012 07:31 PM, jimbo1qaz wrote:
> spots[y][x]=mark fails with a "'str' object does not support item assignment" error,even though:
>>>> a=[["a"]]
>>>> a[0][0]="b"
> and:
>>>> a=[["a"]]
>>>> a[0][0]=1000000
> both work.
> Spots is a nested list created as a copy of another list.

But
a = "a"
a[0] = 'c'
fails for the same reason, which is that strings in Python are immutable..



More information about the Python-list mailing list