11. Danger, Will Robinson! (Wrong Row and Column)


#1



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

When changing the guess of column and row to 'x' I am doing the function for guess_row-1 and guess_col-1 because the lists begin at 0 instead of 1. However, Codeacademy says I have to use guess_row and guess_col values for the coordinate to change to 'x', however it marks the wrong coordinate, yet it says the lesson is correct... Am I missing something here?


#I am using this code and it prints out the correct location of 'X' yet I am told I am doing it incorrectly:
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)
#This is the code that they say is correct but shows a wrong coordinate on the board:
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)


#2

Hello @bkeltjens,

You are correct. However, in this course, it is assumed that the user knows about list and string indices starting from 0, and so doesn't go into the depths of making it user friendly. If you were making this project original, however, you could definitely put that!


#3

Python starts counting from 0, so to make it input the correct value you would have to add 1 +1 for whatever number the user inputs. :slight_smile: