'str' object does not support item assignment

Ian Kelly ian.g.kelly at gmail.com
Sun Sep 23 14:45:09 EDT 2012


On Sun, Sep 23, 2012 at 12:31 PM, jimbo1qaz <jimmyli1528 at gmail.com> 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.

There's not enough information to go on here to even speculate what
might be causing the error, beyond "spots probably does not have the
structure you think it does".  Please post the code that you're
actually running along with the full error traceback, and then maybe
we can help you out.  Also try printing the value of spots just before
the assignment and see what it actually looks like.



More information about the Python-list mailing list