I know I'm doing something wrong, but what is it?


#1

spits back: Traceback (most recent call last):
File "python", line 35, in
NameError: name 'i' is not defined

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


#2

i and j are not defined. Perhaps you are trying to write this?

i = guess_row
j = guess_col

If so, I would suggest not doing it since we were not instructed to create any secondary variables.

board[guess_row][guess_col]

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.