0

I have an array with 20 values, but value 16 is incorrent and must be replaced with the correct value. How can I do that?

texture[16] = 'sky13.jpg'

That code does not work for some reason. The error is "'tuple' object does not support item assignment"

Joost Verbraeken
  • 883
  • 2
  • 15
  • 30

3 Answers3

2

You're working with a tuple instead of a list. Convert it to a list first

texture = list(texture)
texture[16] = 'sky13.jpg
Stack of Pancakes
  • 1,881
  • 18
  • 23
1

check what texture is

type(texture)

if it is tuple then convert it to list

textute = list(texture)

in python simple way to talk tuple object is immutable list object

more about differences is here What's the difference between lists and tuples?

Community
  • 1
  • 1
k.rozycki
  • 635
  • 1
  • 5
  • 12
0

Tuples in Python are **inmutable**, which means that you can't change the value once you assign it!

You need to convert the tuple to a list:

listOfTextures = list(texture)

And then you will be able to change the values you want to.

Oscar Bralo
  • 1,912
  • 13
  • 12