Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: 'str' object does not support item assignment

17 views
Skip to first unread message

MRAB

unread,
Sep 23, 2012, 2:47:38 PM9/23/12
to pytho...@python.org
On 2012-09-23 19:31, 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.
>
The error suggests that spots[y] is actually a string. Printing
repr(spots) and repr(spots[y]) should tell you whether it is.

jimbo1qaz

unread,
Sep 23, 2012, 2:55:09 PM9/23/12
to pytho...@python.org
ya, I'm an idiot. I accidentally made a string instead of an array.

jimbo1qaz

unread,
Sep 23, 2012, 2:55:09 PM9/23/12
to comp.lan...@googlegroups.com, pytho...@python.org
On Sunday, September 23, 2012 11:48:11 AM UTC-7, MRAB wrote:
0 new messages