How do I set the list element


How do I set the list element at guess_row, guess_col to “X” in the Battleship game (step 11)?

FAQ: Learn Python - Battleship - Danger, Will Robinson!

Remember how to call an element from a 1-dimensional list? (i.e. list[2])
So in a 2-dimensional list, you add more info to it --> list[2][3]
To put it in the context, I had board[guess_row][guess_col] and set it equal to string X.


To add to the above, once we declare which index is for the row, and which is for the column, we cannot switch that around.


The row index is always first, and column index always second.


Thank you so much @cirrus11. I totally get it now!


Thank you for the additional information @mtf! I appreciate it !


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