title: IndexError on my Battleships strategy in python
body: <p>When running my strategy in the battleships program, I receive an IndexError: list index out of range. The code works fine for most of the squares on the map but on the squares close to the outline of the map such as when row = 0 the error appears. 
  My battleships strategy picks random moves on the map storing each guess in the lastHit list outside the function. If a guess hits a ship, then next turn, row and col will take the last two values in the lastHit list and then check the adjacent squares around it using the criteria set in the if statements. The error code appears on line 10 where the first if statement is.</p>
  
  <pre><code>lastHit = [1, 1]
  
  def chooseMove():
  
      global playerBoard, opponentBoard
  
      row = lastHit[0]
      col = lastHit[1]
  
      if (opponentBoard[row][col] == const.HIT) and (opponentBoard[row - 1][col] != opponentBoard[5:][:5]) and (row - 1 != -1):
      row -= 1
      if ((opponentBoard[row][col] == const.MISSED) or (opponentBoard[row][col] == const.HIT)) and (opponentBoard[row + 2][col] != opponentBoard[5:][:5]) and (row + 2 != 12):
          row += 2
          if ((opponentBoard[row][col] == const.MISSED) or (opponentBoard[row][col] == const.HIT)) and (opponentBoard[row - 1][col - 1] != opponentBoard[5:][:5]) and (col - 1 != -1):
          row -= 1
          col -= 1
              if ((opponentBoard[row][col] == const.MISSED) or (opponentBoard[row][col] == const.HIT)) and (opponentBoard[row][col + 2] != opponentBoard[5:][:5]) and (col + 2 != 12):
              col += 2
              if ((opponentBoard[row][col] == const.MISSED) or (opponentBoard[row][col] == const.HIT)) and (opponentBoard[row][col] != opponentBoard[5:][:5]):
                  while (opponentBoard[row][col] == const.MISSED):
                          row = randint(0,len(opponentBoard)-1)
                          col = randint(0,len(opponentBoard[row])-1)
                  else:
                      lastHit[0] = row;
                      lastHit[1] = col;
                      return row, col
              else:
                  lastHit[0] = row;
              lastHit[1] = col;
              return row, col 
          else:
              lastHit[0] = row;
              lastHit[1] = col;
              return row, col
          else:
          lastHit[0] = row;
          lastHit[1] = col;
          return row, col
          else:
          lastHit[0] = row;
          lastHit[1] = col;
          return row, col
      else: 
          while (opponentBoard[row][col] == const.HIT) or (opponentBoard[row][col] == const.MISSED):
              row = randint(0,len(opponentBoard)-1)
              col = randint(0,len(opponentBoard[row])-1)
          else:
          lastHit[0] = row;
          lastHit[1] = col;
          return row, col
  </code></pre>