errors

self.heart[1] = onscreenimage

it says classname instance has no attribute heart

for i in range(1,5):
self.hearts[i] = onscreenimage

it says ‘int’ object is unsubscriptable

for i in range(1,5):
self.hearts = onscreenimage

it creates five images but if I try to change some attribute
self.hearts[self.index].setPos() - ‘int’ object is unsubscriptable

self.hearts[0].setPos - classname instance has no attribute heart

I want to store a certain number of images for after I can change em with setImage having access them through an index variable

Create it as list first:

self.hearts = []
for i in range(1,5):
  self.hearts.append(OnscreenImage(your parameters))

Looks to me as if somewhere in your code you are setting self.hearts to be an integer. Thus you cant subscript off an integer.

Do what pro-rsoft said :slight_smile:

it works but as the same before if I try to change ‘self.hearts’ attribute I get that errors.

I don’t know why but it is working:

self.hearts = {}
for i in range(1, self.maxHearts):
   self.hearts[i] = OnscreenImage

thank your support!