Battleship, find the X spot


#1

So, the site wants me to do this:
board[guess_row][guess_col] = "X"
But that changes the wrong element, because the lists are indexed 0:4, not 1:5. And it won't allow the user to even guess 5! So the correct code would be:
board[guess_row-1][guess_col-1] = "X"

The other solution for this is to make guesses = raw input -1. I guess that is more permanent too though. might try that.


#2

Or just refer to them by 0..4, you could use animals as indexes for that matter, it'll be arbitrary no matter what you do.

But yes, modify it when taking input (and possibly when printing) so that the logic in the rest of the code is consistent.

As an alternative, you could add an extra row and column that is never used (you can use None as the value), not exactly my favourite solution though.


#3

I don't like 0..4 cause it's not intuitive. if you show this game to a friend that doesn't know how it works, he'll try to use 1..5 cause it makes sense.
I ended up changing input in the part where this is the condition to get the green check mark, then in the next one I just did
board[guess_row-1][guess_col-1] = "X"