I stopped when the Battleship course asked me to test my code before going any further and I realize that I sometimes can get a code to work (actually to get accepted by CC Console) without understanding what it really do.
So for example, in the Hide... lesson, we're generating random coordinates for our ship to be hidden in. But I still can't understand the idea of substracting 1 from the length of the board.
def random_row(board): return randint(0, len(board) - 1) def random_col(board): return randint(0, len(board) - 1)
Why do we need to substract 1 ?
Also, is there any reason for feeding board as a parameter since we're going to call it later anyway ?
I understand that we can feed a variable as a parameter for a function if we're gonna print it right inside the function (as in the print_board function) but not in this example.