title: Python - Matrix IndexError exception not working
body: <p>I am trying to write a function which enables a move 1 unit to the left (in the x-axis) in a grid. It should only work if there is a valid coordinate to the left, and if not (i.e. the start point is on the edge of the grid), the function should return <code>None</code>. Here is my attempt:</p>
  
  <pre><code>def left_move(point):
      try: 
          LEFT = grid[point[1]][point[0]-1]
      except IndexError: 
          return None
      if LEFT == '.':
          change = [-1,0]
          for idx, amount in enumerate(change):
              point[idx]+=amount
          return point
      return None
  </code></pre>
  
  <p>Say the starting point is <code>[0,3]</code> and therefore on the edge of the grid and I only run the top part of the code:</p>
  
  <pre><code>def left_move(point):
      try: 
          LEFT = grid[point[1]][point[0]-1]
      except IndexError: 
          return None
  </code></pre>
  
  <p>It returns <code>None</code> as expected. But if the whole block is executed it returns <code>[-1,3]</code> which is outside of the grid and shouldn't be allowed by the <code>try-except</code> . Why is this? And how can it be corrected? </p>