...and Seek! why did they put


#1

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

Could someone explain why did they change?:

return randint(0, len(board) - 1)
to
return randint(0, len(board[0]) - 1)

appreciated


#2

Hi @parafian12,

The Battleship! board is a square, therefore the number of columns is the same as the number of rows. However, in the final exercise, 13: Extra Credit, you are invited to modify the game. You might choose to use a rectangular board in which the number of columns is not the same as the number of rows. In that case, len(board[0]) would represent the number of cells in row 0, which would also be the number of columns in the board. Then, randint(0, len(board[0]) - 1) would provide a randomly chosen column number.


#3

Thanks, you're awesome!


#4