+ 1
Please explain me why is this so? # inside
Can't figure out why these operations lead to different results. I thought that "a += x" is a compact version of "a = a + x", but it doesn't act the same way. https://code.sololearn.com/c6elVIArduRn/?ref=app
1 ответ
+ 1
Because b acts as a reference to a. Then when a is reassigned, using the different method, b is considered a new list. Seen here by printing the ids before and after
https://code.sololearn.com/c7qgg20P3ql0/?ref=app