title: Python - IndexError: string index out of range (Beginner)
body: <p>first of all, sorry if this is already answered I've looked through past Q's but no luck.</p>
  
  <p>My problem is: I've gone through the Python+libtcod tutorial on <a href="http://roguebasin.roguelikedevelopment.org/index.php/Complete_Roguelike_Tutorial,_using_python%2Blibtcod" rel="nofollow">Roguebasin</a> once and doing it again while making my own modifications.</p>
  
  <p>I'm trying to make a hardcoded map instead of a randomly generated one.</p>
  
  <p>The code so far will not show a window or anything I'm just running and hope it closes with no errors. BUT, I keep getting this:</p>
  
  <pre><code>Traceback (most recent call last):
    File "superrogue.py", line 85, in &lt;module&gt;
      make_map()
    File "superrogue.py", line 68, in make_map
      if MAP_FILE[x][y] in TILE_NAMES:    #Find the tile's name---
  IndexError: string index out of range
  </code></pre>
  
  <p>The whole "string index out of range" is what I've been beating my head against the wall all afternoon and evening.</p>
  
  <p>Here's the code so far:</p>
  
  <pre><code>#---Imports-------------------------------------------------------------
  import libtcodpy as libtcod
  
  #---Program Labelings---------------------------------------------------
  TITLE = 'Roguetest'
  VERSION = '0.01a'
  
  #---Setup Variables-----------------------------------------------------
  SCREEN_WIDTH = 80
  SCREEN_HEIGHT = 50
  LIMIT_FPS = 20
  #MAP_FILE = open('Maps/Test.txt', 'r')
  #MAP_FILE = MAP_FILE.readlines()
  MAP_FILE = ['XXXX',
              'X==X',
              'X..X',
              'X..X',
              'X==X',
              'XXXX',
              ]
  MAP_WIDTH = len(MAP_FILE[0])
  print MAP_WIDTH
  MAP_HEIGHT = len(MAP_FILE)
  print MAP_HEIGHT
  
  
  #---Dictionaries--------------------------------------------------------------
  COLORS = {
              'dark_new' : libtcod.Color(255, 0, 255),
              'light_new' : libtcod.Color(255, 0, 255),
              'dark_pavement' : libtcod.Color(20, 20, 20),
              'light_pavement' : libtcod.Color(50, 50, 50),
              'dark_sidewalk' : libtcod.Color(80, 80, 80),
              'light_sidewalk' : libtcod.Color(120, 120, 120),
              'dark_wall' : libtcod.Color(100, 100, 100),
              'light_wall' : libtcod.Color(180, 180, 180)
              }
  
  TILE_NAMES = {
                  'X' : 'wall',
                  '.' : 'pavement',
                  '=' : 'sidewalk'
                  }
  
  #---Classes-------------------------------------------------------------
  class Tile:
      def __init__(self, name):
          self.name = name
          self.darkcolor = COLORS['dark_' + self.name]
          self.lightcolor = COLORS['light_' + self.name]
          self.blocks = False
          self.blocks_sight = False
          self.inside = False
  
  
  #---Functions-----------------------------------------------------------
  def make_map():
  
      map = [[ Tile(name='new')
          for x in range(MAP_WIDTH) ]
              for y in range(MAP_HEIGHT) ]
  
      for x in range(MAP_WIDTH):
          for y in range(MAP_HEIGHT):
              print (x, y)
              if MAP_FILE[x][y] in TILE_NAMES:    #Find the tile's name---
                  map[x][y].name = TILE_NAMES[MAP_FILE[x][y]]
  
              map[x][y].darkcolor = COLORS['dark_' + map[x][y].name]
              map[x][y].lightcolor = COLORS['light_' + map[x][y].name]
  
              if MAP_FILE[x][y] == 'X':   #The WALL tile------------------
                  map[x][y].blocked = True
                  map[x][y].block_sight = True
              elif MAP_FILE[x][y] == '.': #The PAVEMENT tile--------------
                  map[x][y].blocked = False
                  map[x][y].block_sight = False
              elif MAP_FILE[x][y] == '=': #The SIDEWALK tile--------------
                  map[x][y].block_sight = False
                  map[x][y].ped_walkable = True
  
  
  make_map()
  </code></pre>
  
  <p>Thanks.</p>