Iterating through 1 list and by using arguments from another list

I’m trying to write a maze game, where I create the walls using a Wall class. The Wall class has a method for building walls requiring rectangle sizes (x,y, width, height) which is kept in a sizeList e.g. sizeList = [(40,280,2,180),(80,315,2,80)]. I created a loop to instantiate 25 wall objects, but want to match the list with the relevant sizes in the sizeList e.g.
for oWall in wallList:
oWall.buildWall((*sizeList)

How can I get the arguments to be accessed 1 at a time in the order they are stored in the sizeList?

class Wall():
def __init__(self, window):
        self.window = window
def buildWall(self,size):
        self.size = size  #dimension of the wall
        wall = pygame.draw.rect(self.window,(0,255,0),pygame.Rect(size),0)

wallList = []
for i in range(25):
    oWall = Wall(window)
    wallList.append(oWall)

for oWall in wallList:
    oWall.buildWall((*sizeList)
for size, wall in zip(size_list, wall_list):
    wall.build_wall(size)
1 Like

Great. It worked like a charm. Thanks for your help.

2 Likes

Incidentally, you may want to use:

wall_list = [Wall(window) for _ in range(25)]
1 Like

Yup. That worked, too. But I’m an old fashioned kind of guy, and more used to seeing the loop the old-fashioned way.