Battleship! Possible bug


#1



https://www.codecademy.com/courses/python-beginner-en-4XuFm/1/2?curriculum_id=4f89dab3d788890003000096#


I get no error.


I expect to pass. My code is correct but the output is wrong. It puts and "X" 1 row and 1 column higher than entered. When I added a -1 to my code so the output is correct. I get this error: Oops, try again. You're updating 'guess_row - 1' and 'guess_col - 1' instead of 'guess_row' and 'guess_col'., and it won't let me pass.


Replace this line with your code. 

#Incorrect code that lets me pass
# Write your code below!
if guess_row == ship_row and guess_col == ship_col:
    print "Congratulations! You sank my battleship!"
else:
    print "You missed my battleship!"
    board[guess_row][guess_col]="X"
    print_board(board)

#Correct code, doesn't let me pass
# Write your code below!
if guess_row == ship_row and guess_col == ship_col:
    print "Congratulations! You sank my battleship!"
else:
    print "You missed my battleship!"
    board[guess_row-1][guess_col-1]="X"
    print_board(board)


#2

if you want to compensate for the fact that humans start counting at one, and lists at zero, subtract one from the user input, its a lot easier


#3

I'll try. Thanks!!!!!!!


#4

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