+ 3
how can I create a game board?
game board must be a 2d lists for easly access and change but i cant create it. someone help?
3 Answers
+ 2
let's say you wanna create a 3x3 board. first what you do is create a 3Ă3 array and feel it up with * or - (doesn't matter, anything you like). now to print it in the form of a board, you will need a for loop( or while loop, depends on what you prefer) inside another for/while loop. in the inside loop, you print the contents of the row. eg
for i in range(3):
for j in range(3):
print(board[i][j],end=' ')
print('\n', end =' ')
that should print the board
to update the board via user input, you will need the user to specify two inputs, the row, and the column of the position in the board they want to change
+ 2
thanks
0
for creating the board, board = [['*', '*', '*'], ['*', '*', '*'], ['*', '*', '*']]