+ 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?

12th Oct 2016, 10:27 AM
Kaziu (Mark K.)
Kaziu (Mark K.) - avatar
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
12th Oct 2016, 11:13 AM
Fhatuwani Luvhengo
Fhatuwani Luvhengo - avatar
+ 2
thanks
12th Oct 2016, 11:51 AM
Kaziu (Mark K.)
Kaziu (Mark K.) - avatar
0
for creating the board, board = [['*', '*', '*'], ['*', '*', '*'], ['*', '*', '*']]
12th Oct 2016, 11:32 AM
Fhatuwani Luvhengo
Fhatuwani Luvhengo - avatar