What is a result of following code block execution:
a = b = [1, 2, 3]
b[2] = 4
Variables a and b are lists in this example. But they point to the same memory area.
Python list datatype is mutable (meaning that it can be modified in place).
Since both variables point to the same data and it can be modified in place, then after variable b is updated, variable a will change as well.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Sign Up Now
or Subscribe for future quizzes