0
Why assignment in python is dynamic??
hi, consider below: a=[1,2,3] b=a a[0]="test" print(b) output is: >>>["test",2,3] why the value of "b" changed dynamically with the change in variable "a"?? this a bit awkward if you are coming from C language background
3 Answers
+ 2
It's the same thing in C, with nothing to do with dynamicity. You are assigning the reference of a to b. The variable b refers to the same object as a. Coming from a C background shouldn't make this look any awkward. Instead, it should make more sense. Read into the differences between shallow copy and deep copy.
https://stackoverflow.com/questions/184710/what-is-the-difference-between-a-deep-copy-and-a-shallow-copy
+ 2
Mugahed Izzeldin Osman Simpler than it sounds. :>
https://code.sololearn.com/coU1gFS69ytS/?ref=app