# 11. Danger, Will Robinson!

#1

I get stucked. Сode looks like correct, but it doesn't change "O" to "X". Help, please.

``````from random import randint

board = []

for x in range(0, 5):
board.append(["O"] * 5)

def print_board(board):
for row in board:
print " ".join(row)

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_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

if guess_row == ship_row and guess_col == ship_col:
print "Congratulations! You sank my battleship!"
else:
print "You missed my battleship!"
print board[guess_row][guess_col] == 'X'
print_board(board)``````

#2

Well you've identified the issue, so go look at the part that is responsible for changing to `"X"` and consider what that is supposed to look like.

If you really think it should look that way, then I suggest you do a little experimenting at the bottom of your code where you print the board, try to set some location to X, and then print it again to see if you succeeded.

#3

You have to change comparison element which is double =. What I'm trying to say that if you change print board[guess_row][guess_col] == 'X' with print board[guess_row][guess_col] = 'X' it will work

#4

Yes, I tried this. But it doesn't work too.
File "python", line 34
print board[guess_row][guess_col] = 'X'
^
SyntaxError: invalid syntax

#5

Попробуй вместо апострофа кавычки тогда

#6

try to change
print "You missed my battleship!"
print board[guessrow][guess_col] == 'X'_
printboard(board)_

to following

print "You missed my battleship!"
board[guess_row][guess_col] = "X"
print_board(board)

#7

Tried this too. Same output

#8

that's weird 'cause it works for me

#9

Weird, but true

#10

This is what worked for me
else:
print "You missed my battleship!"
board[guess_row][guess_col] = "X"
print_board(board)
I think it is just the print in front of board[guess_row][guess_col] = "X" making it not work

#11

Yes, you're right. Thanks