Using for loop to name attributes.

So if I want to use a for loop like this:

for x in self.maxZombieInThisWave:
            self.zombie(x) = loader.loadModel("zombie")
            x/3 = r
            r[0] = rowUp
            len(x) = length

but this doesn’t work, how can I create an attribute depending on a for loop?

Also it gives me can’t assign to operator for x/3 = r and len(x) = length. And " can’t assign to function call" for self.zombie(x) = loader… What’s with this?

I’m not sure I understand the question, and that snippet won’t work - it looks like you’re using brackets instead of square brackets to access list elements, and I’m not sure where “r”, “rowUp” or “length” get defined. :S

Try inverting your name definitions, ie x/3 = r should probably be r = x / 3. Accessing a list should be myList[x] instead of myList(x).

I assume self.maxZombieInThisWave is an integer that says how many zombies you need to spawn.

self.zombies = []
if self.maxZombieInThisWave > 0:
  for num in range(self.maxZombieInThisWave-1):
    self.zombies[num] = loader.loadModel("zombie")
    # self.zombies[num] now is the current zombie. do with it whatever you need.
    # e.g. move it num units up:

Beside that, I suggest you learn Python first. Starting with Panda3D is like trying to fly a helicopter before being able to drive a car.

Okay I see, thank your very much.

Also I know python, but I’m a beginner.