Слияние массивов вместо добавления в Python ⇐ Python
-
Anonymous
Слияние массивов вместо добавления в Python
I'm attempting to append these two arrays as they're built but am getting unexpected results in Python:
This = [] That = [] This.append('A') That.append(This) This.append('B') That.append(This) print(That) Expected results: [['A'],['A','B']]
Actual results: [['A','B'],['A','B']]
Источник: https://stackoverflow.com/questions/780 ... -in-python
I'm attempting to append these two arrays as they're built but am getting unexpected results in Python:
This = [] That = [] This.append('A') That.append(This) This.append('B') That.append(This) print(That) Expected results: [['A'],['A','B']]
Actual results: [['A','B'],['A','B']]
Источник: https://stackoverflow.com/questions/780 ... -in-python