title: Index Error: list index out of range (Python) -- Printing to Console
body: <p>I am having trouble following the error that I am getting which is:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/Users/joelwilliams/Desktop/delete me", line 30, in &lt;module&gt;
      v.writef( '======================', 10, 10 )
    File "/Users/joelwilliams/Desktop/delete me", line 24, in writef
      self.write( word )
    File "/Users/joelwilliams/Desktop/delete me", line 15, in write
      self.l[ self.y ] [ self.x : ( self.x + len( word ) ) ] = word
  IndexError: list index out of range
  </code></pre>
  
  <p>The main code is here:</p>
  
  <pre><code>class board():
      def __init__( self ):
          self.x, self.y = 0, 0
          self.l = []
          self.screenWidth, self.screenHeight = 0, 0
  
      def createBoard( self ):
          listBig = [ ['`'] * self.screenWidth for _ in range( self.screenHeight ) ]
  
      def setup( self, sw, sh ):
          self.screenWidth = sw - 1
          self.screenHeight = sh - 1
  
      def write( self, word ):
          self.l[ self.y ] [ self.x : ( self.x + len( word ) ) ] = word
  
      def draw( self ):
          for v in self.l:
              print(''.join(v))
  
      def writef( self, word, y, x ):
          self.cursorPosX = x - 1
          self.cursorPosY = y - 1
          self.write( word )
  
  v = board()
  v.setup( 75, 20 )
  v.createBoard()
  
  v.writef( '======================', 10, 10 )
  v.writef( '=                    =', 11, 10 )
  v.writef( '=   Pls Work.        =', 12, 10 )
  v.writef( '=                    =', 13, 10 )
  v.writef( '======================', 14, 10 )
  
  v.draw()
  </code></pre>
  
  <p>The desired result is for the console to display:</p>
  
  <pre><code>           ======================
             =                    =
             =   Pls Work.        =
             =                    =
             ======================
  </code></pre>
  
  <p>I used <a href="https://stackoverflow.com/questions/16259925/making-a-list-independent-of-itself">this</a> as a guide to create the above code
  thanks in advance!</p>