I tried to include a second battleship to my board by adding a second random row and line. I print the two random places in my code for debugging. But when I enter these random places in the Guess row and Guess col, the game says it is not the right place.
It should say You sunk my battleship, but it just keeps giving me turns. All of the wrong guesses give the right message, but for some reason I cannot guess the right col and row.
Can someone please take a look at my code below and help me in the right direction?
from random import randint board =  # Makes 5 by 5 board for x in range(5): board.append(["O"] * 5) def print_board(board): for row in board: print " ".join(row) # Start of game print "Let's play Battleship!" print_board(board) # Two random ships in board def random_row1(board): return randint(0, len(board) - 1) def random_col1(board): return randint(0, len(board) - 1) def random_row2(board): return randint(0, len(board) - 1) def random_col2(board): return randint(0, len(board) - 1) ship_row = (random_row1(board) or random_row2(board)) ship_col = (random_col1(board) or random_row2(board)) # Prints rows and cols for debugging print "row1", random_row1(board) print "col1", random_col1(board) print "row2", random_row2(board) print "col2", random_col2(board) # Game loop start, 4 turns for turn in range(4): guess_row = int(raw_input("Guess Row:")) guess_col = int(raw_input("Guess Col:")) # if statement for good guess if guess_row == ship_row and guess_col == ship_col: board[guess_row][guess_col] = "X" print "Congratulations! You sunk my battleship!" break # else statement for wrong guess else: if (guess_row < 0 or guess_row > 4) or (guess_col < 0 or \ guess_col > 4): print "Oops, that's not even in the ocean." elif(board[guess_row][guess_col] == "X"): print "You guessed that one already." else: print "You missed my battleship!" board[guess_row][guess_col] = "X" # Print (turn + 1) print_board(board) print "You have 4 turns, this is turn", turn + 1 if turn == 3: print "Game Over"