So, I notice that while creating this Battleship code there is a clear possibility for a user of this code to pick row 0 (or column 0 for that matter), and that would be acceptable since the code interprets it as the first row (due to list indices starting from 0). Similarly picking row 5 would yield the same result as picking something off the board, which is yet another fundamental flaw with the code.
I have tweaked it a bit so that it satisfies my prerequisites to be an easy to use and intuitive code.
Please have a look and tell me if my code makes sense (I've pasted it below)
And am I the only one who gets annoyed by the fact that the "X" for incorrect column and row replaces WHOLE ROWS instead of replacing one particular element of that row?
from random import randint board =  for x in range(1, 6): board.append(["O"] * 5) def print_board(board): for row in board: print " ".join(row) print_board(board) def random_row(board): return randint(1, 5) def random_col(board): return randint(1, 5) ship_row = random_row(board) ship_col = random_col(board) guess_row = int(raw_input("Guess Row:")) guess_col = int(raw_input("Guess Col:")) print ship_row print ship_col # Write your code below! if guess_row == ship_row and guess_col == ship_col: print "Congratulations! You sank my battleship!" else: if guess_row not in range(1, 6) or\ guess_col not in range(1,6): print "Oops, that's not even in the ocean." elif board[guess_row - 1][guess_col - 1] == 'X': print "You guessed that one already." else: print "You missed my battleship!" board[guess_row - 1] = "X" board[guess_col - 1] = "X" print_board(board)