Answer the question
In order to leave comments, you need to log in
What's with the weird assignment behavior in python?
After a seemingly unambiguous assignment, the value changes in two places at once.
print (squares)
squares[j][orientation][1] = place
print (squares)
#j = 0, orientation = 1, place = 5
[, ]
[, ]
Answer the question
In order to leave comments, you need to log in
At indexes 1 and 3, you have the same object.
A possible solution (probably not optimal, you know better from the context) -
print (squares)
tmp=squares[j][orientation][:] # создаём копию
tmp[1] = place
squares[j][orientation]=tmp
print (squares)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question