title: Generating two linked 2D array positions
body: <p>I am creating a battleships game in Python. I am trying to generate a two position ship but the while loop that makes sure the positions are linked goes on forever. I am using Python 2.7</p>
  
  <pre><code>from random import randint
  board = []
  for x in range(5):
      board.append(["O"] * 5)
  def print_board(board):
      for row in board:
          print " ".join(row)
  print "Let's play Battleship!"
  print_board(board)
  def random_row(board):
      return randint(0, len(board) - 1)
  def random_col(board):
      return randint(0, len(board[0]) - 1)
  ship_row1 = random_row(board) + 1
  ship_col1 = random_col(board) + 1
  ship_row2 = random_row(board) + 1
  ship_col2 = random_col(board) + 1
  print "Generating ship..."
  while (ship_row2 != ship_row1 + 1 or ship_row2 != ship_row1 - 1):
      ship_row2 = random_row(board) + 1
  while (ship_col2 != ship_col1 + 1 or ship_col2 != ship_col1 - 1):
      ship_col2 = random_col(board) + 1
  print ship_row1
  print ship_col1
  print ship_row2
  print ship_col2
  </code></pre>