[Tutor] Problems changing a list item in place ?

Chris McCormick cmccormick@thestate.com
Mon, 11 Feb 2002 11:56:54 -0500


Hello all,
    I have a program with a two-dimensional list called map.  After it has already been populated, I want to do this:

     map[y_box][x_box][0] = selected_tile

     But I get this error:

   File "map_edit.py", line 270, in main
    map[y_box][x_box][0] = selected_tile                        # Change value of the tile
TypeError: object doesn't support item assignment

  y_box and x_box are indexes; the statement "print map[y_box][x_box]" works fine.  selected_tile is just an integer, though it shouldn't matter.

I thought you could change list items in-place by assignment.  Are multi-dimensional lists different?

Thanks in advance,
Chris