title: I am trying to program a 2d shooter game in pygame and it shows an index error `IndexError: list index out of range`
body: <pre><code>animation_types = ['idle', 'run', 'jump']
    for animation in animation_types:
      temp_list = []
    num_of_frames = len(os.listdir(f'img/{self.char_type}/{animation}'))
    for i in range(num_of_frames):
       img = pygame.image.load(f'img/{self.char_type}/{animation}/{i}.png')
       img = pygame.transform.scale(img, (int(img.get_width() * scale), int(img.get_height() * scale)))
       temp_list.append(img)
       temp_list = []
    self.animation_list.append(temp_list)
     
    self.image = self.animation_list[self.action][self.frame_index]
    self.rect = self.image.get_rect()
    self.rect.center = (x, y)
  </code></pre>
  <blockquote>
  <p>IndexError: list index out of range</p>
  </blockquote>
  <p>when I run this part of the code it shows the index error &quot;out of range&quot; and I have tried everything but nothing works.</p>