0
I am trying to create a program in Python 3.6.1 that creates a board according to the size typed by the end user and prints the result in the shell.
It needs to be presented as text, and cannot use any library. As much as the library is internal.
Example: if the user enters a board with 10 rows and 15 columns. The program would have to generate this board 10x15. Since all its values must be cells filled by strings. Because, later, the user will enter the value "P", for example, it will change a cell predefined by me. Then the board would be printed again with the value of the previously defined cell by me.
EX: User enters initial information:
Insert number of lines: 10
Enter the number of columns: 15
the board would initially look like this:
0123456789..... 0 XXXXXXXXXXXXXXX 1 XXXXXXXXXXXXXXX 2 XXXXXXXXXXXXXXX 3 XXXXXXXXXXXXXXX 4 XXXXXXXXXXXXXXX 5 XXXXXXXXXXXXXXX 6 XXXXXXXXXXXXXXX 7 XXXXXXXXXXXXXXX 8 XXXXXXXXXXXXXXX 9 XXXXXXXXXXXXXXX
Then the user would insert P in the 3x3 coordinates, for example:
enter what you want in row 3 column 3: P <<< user typed P
After that, the board would be printed again, with the following result:
0123456789..... 0 XXXXXXXXXXXXXXX 1 XXXXXXXXXXXXXXX 2 XXXXXXXXXXXXXXX 3 XXXPXXXXXXXXXXX #o P seria inserido nessa linha. Exatamente onde foi mandado. 4 XXXXXXXXXXXXXXX 5 XXXXXXXXXXXXXXX 6 XXXXXXXXXXXXXXX 7 XXXXXXXXXXXXXXX 8 XXXXXXXXXXXXXXX 9 XXXXXXXXXXXXXXX
Can anyone tell me how to do that?
The user questions part, I know how to do.
My problem is with the board. I have no idea how to leave as I said. Would creating a matrix be a good solution? Or is there a less complicated way? I have tried several ways to generate this board, but without success.
I do not know if I am wrong in logic or syntax, because I started programming with python recently.
I did a lot of research on a possible solution, but found no clear information.
I have more experience with php currently.
All help is welcome.
From now on, thank you.
PS: The closest result I could get to what I needed was this:
linhas = int(input('insira a quantidade de linhas:'))
colunas = int(input('insira a quantidade de colunas:'))
celula = "X"
for a in range(linhas):
print(celula*colunas)
He generates everything apparently as needed. But that’s not quite how the end result should look. I need each X printed on the screen to be a dynamic "space", where each can be changed later with any other value according to the coordinates. Ex: F in row 4 column 7 . I don’t know how to do this.