0

I read that in order to change the values in a 2D array, you just need to specify the index of the array in which our number is located, then specify the index of the number already in the array itself. But for some reason it does not work properly . I want to change in 2 tables, 3 values (index 1,2) and not all. Here's what the console outputs

sim=str(input('Введите символ для перемещения- '))
dlin=int(input('Введите количество строк в длину- '))
hi=int(input('Введите количество строк в высотку- '))
text=[[' ']*dlin]*hi
text[1][2]=sim
for i in text:
    print(i)

If you write an array manually and use this method, it works I do not know what to do I job in VS code

ERHA
  • 1
  • Show the output and other textual information as properly formatted text in the questions, not as comment, image or external link. – Michael Butscher Dec 23 '22 at 19:14
  • When you define `text`, the inner object `[' ']*dlin` only exists once and is repeated `hi`times. So if you change one element, it will change all references and look as if you changed the entire column. – Dr. V Dec 23 '22 at 19:15

0 Answers0