Board indexing question


Why is board indexed at 0 in the rand_col function but not also in the rand_row function?

FAQ: Learn Python - Battleship - And Seek

I have the exact same question. Looking forward to hear from someone about this question.


Actually, both rows and columns are zero-indexed. If you are referring to this,

rand_col = randint(0, len(board[0] - 1))

it has to do with a non-square board having more or less columns than rows. We cannot set up the rows with the correct number of columns without knowing their length.


Here is the solution :slight_smile:

Thank for your reply too.


You’re welcome. Sorry for all the typos… Need new glasses.


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