I am trying to create a game like Battleship in Python. My current code hides a ship and if you guess the location of the ship (the coordinates are displayed for debugging purposes). My error is that it is changing the text for an item for all the rows rather than just one.
from random import randint
board = []
board = [["O"]*5]*5
def print_board(board):
for row in board:
print(" ".join(row))
print_board(board)
ship_row = randint(0, len(board)-1)
ship_col = randint(0, len(board[0])-1)
print(ship_row, ship_col)
gr = input("Guess row: ")
gc = input("Guess column: ")
if gr == ship_row and gc == ship_col:
board[ship_row][ship_col] = "X"
print_board(board)