title: How to solve the error list index out of range ? (On python using pygame and sys)
body: <p>I'm beginning in python and I wanted to follow a simple guide to make a little game, but I encountered a problem and I can't seem to fix it. The problem is that after running my program, my IDE is showing the &quot;IndexError: list index out of range&quot; but I don't know why, I suspect one part of my code for this problem ( I think it's <code>TileColour[map1[row][col]]</code>) but I can't figure what's wrong with it. So I came here hoping you could help me with that problem. Thanks for the help!</p>
  <pre><code>import pygame, sys
  
  #Define which tile to use
  L = 0 #LAVA
  R = 1 #ROCK
  F = 2 #FOREST
  G = 3 #BURNEDGRASS
  
  
  #Tiles colours
  LAVARED = (207, 16, 32)
  ROCKYGREY = (169,169,169)
  GREENFOREST = (0,76,0)
  BURNEDGRASS = (187, 155, 96)
  
  #Associating Color and Tiles
  TileColour = { L : LAVARED,
                 R : ROCKYGREY,
                 F : GREENFOREST,
                 G : BURNEDGRASS
                 }
  
  #Map Creation
  
  map1 = [[G,G,G,G,G,R,G,G,F,F,F,F,F,F],      #15*15
          [G,L,L,G,G,R,G,G,F,F,F,F,F,F],
          [G,L,L,G,G,G,G,G,F,G,F,F,F,F],
          [G,G,G,R,G,G,G,G,G,G,G,G,G,F],
          [G,G,G,G,G,G,G,G,G,G,G,G,G,G],
          [G,R,G,G,G,R,G,G,G,G,G,R,G,G],
          [G,G,G,G,G,G,R,G,G,G,G,G,G,G],
          [G,G,G,G,G,G,G,G,G,G,G,G,G,G],
          [G,G,G,G,G,G,G,G,G,G,G,G,G,G],
          [G,L,G,G,G,G,G,G,G,R,L,G,G,G],
          [G,L,L,G,G,R,G,L,L,L,G,G,G,G],
          [G,G,G,G,G,G,G,G,G,L,L,G,G,G],
          [G,R,R,G,G,G,G,G,G,G,G,G,R,G],
          [G,G,R,G,G,G,G,G,G,G,G,G,G,G],
          ]
  
  #Map Size
  TILESIZE = 35
  MAPWIDTH = 15
  MAPHEIGHT = 15
  
  #Display
  pygame.init()
  DISPLAY = pygame.display.set_mode((MAPWIDTH*TILESIZE,MAPHEIGHT*TILESIZE))
  
  #Basic HUD
  while True:
      for event in pygame.event.get():
          if event.type == pygame.QUIT:
              pygame.quit()
              sys.exit()
      
      for row in range(MAPHEIGHT):
          for col in range(MAPWIDTH):
              pygame.draw.rect(DISPLAY,TileColour[map1[row][col]],(col*TILESIZE,row*TILESIZE,TILESIZE,TILESIZE))
              
              
      pygame.display.update()
      
  </code></pre>