Question: I have a firestore collection called 'stars' which has: userId, teacherId, documentId and some values.
What i'm trying to do is for each star to get the details about its teacher. (They are in another collection 'users').

I have this method to get all stars (This works):

```
    getAllStars(idDocument: string): void {
        this.dataApi.getAllStars(idDocument).subscribe(stars => {
          this.stars = stars;
      }

```

I have this method to get the details for every teacher (This works): 

```
  getTeacherDetails(id: string): void {
    this.dataApi.getOneUser(id).subscribe(teacher => {
        this.teacher = teacher;
    });
   }

```

What i don't know is how to use a for loop in the getAllStars method to get the details about each teacher. I thought about something like this: this.getTeacherDetails(this.star.teacherId) but don't know how to implement this.
Can you help me? Thank you very much!

Answer: 
Create a list of rectangles:

```py
rect_list = []

```

When you want to add a new rectangle, the append an new [`pygame.Rect`](https://www.pygame.org/docs/ref/rect.html) object to the list:

```py
rect_list.append(pygame.Rect(x, y, width, height))

```

Change the location of the rectangle and draw the rectangles in a loop, in the main application loop:

```py
state = True
while state:
    # [...]

    for rect_obj in rect_list:
        rect_obj.x -= vel
        pygame.draw.rect(win, (0, 0, 255), rect_obj)

    # [...]

```
This answer is derived off Rabbid76's answer, but with a slight modification that allows each individual rect to have it's own `vel` speed and color:

```
class rectangle:
# You can add as many new values as you like, just be wary about changing the other magic methods
    def __init__(top, left, width, height, vel, color=(0, 0, 255)):
        self.vel = vel
        self.pos = (top, left)
        self.size = (width, height)
        self.rect = self.pos + self.size

    def __iter__(self):
        return self.rect

    def __getitem__(self, key):
        if type(key)!=int:
            raise TypeError('invalid key!')
        return self.rect[key]

    def __len__(self):
        return len(self.rect)

    def __reversed__(self):
        return reversed(self.rect)

    def update_rect(self): # This should be called every time you make an adjustment to pos or size
        self.rect = self.pos+self.size

    def move(self, x, y):
        self.pos[0] += x
        self.pos[1] += y
        self.update_rect

    def resize(self, width, height):
        self.size = (width, height)
        self.update_rect

```

Now, you store a list of instances:

```
rect_list = []
rect_list.append(rectangle(top, left, width, height, vel, color)) # You can call this as many times as you want

```

of these classes instead of a list of `pygame.Rect`s, and when it comes time to draw it, the magic methods will come into play, and magically make it a `pygame.Rect` object:

```
for rect in rect_list:
    rect.move(x=-rect.vel, y=0) # Move it negative x
    pygame.draw.rect(win, rect.color, pygame.Rect(rect)) # Draw it.

```