I'm trying to create a program in Python 3.6.1 that creates a tray according to the size entered by the end user and prints the result in the shell.
It needs to be displayed as text, and you can not use any library. As much as the library is internal.
Example: If the user types a tray with 10 rows and 15 columns. The program would have to generate this 10x15 board. Since all values of it must be cells filled by strings. Because the user subsequently enters the value "P", for example, it will change a cell predefined by me. Then the tray would be printed again with the previously pre-defined cell value by me.
EX: The user enters the initial information:
enter the number of rows: 10
enter the number of columns: 15
the board would 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 into 3x3 coordinates, for example:
enter what you want in row 3 column 3: P < user typed P
After this, 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
Does anyone know how to do this?
The questions part to the user, I know how to do.
My problem is with the board. I have no idea how to leave as I said. Would creating an array be a good solution? Or is there a less complicated way? I have tried in many ways to generate this board, but without success.
I do not know if I'm wrong in logic or syntax, since I started programming with python recently.
I researched a lot about a possible solution but found no clear information.
I have more experience with php currently.
All help is welcome.
Thanks in advance.
PS: The closest result I needed to do 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)
It generates everything apparently as accurate. But that's not the way the final result should be. I need each X printed on the screen to be a dynamic "space", where each one can be changed later with any other value according to the coordinates. Ex: F in row 4 column 7. I do not know how to do that.