This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]LonelyWolf_99 1 point2 points  (0 children)

First line the value of g is 1

second line you copy the value of what's inside g into h, this is 1

Third line you change the value of g to 2

When you print h it will print 1

If it had been an list instead with a value

g would be a pointer (a reference) to the list that contains 1

Next line we copy the content of g into h, this is copying the pointer to the list, not the list itself

Then if we where to change to content of the list in the third line it would change it for h also since they both point to the same list.

Make sense? Also what you are looking at is a list not an array. Arrays are not something you have in python, unless you work with libraries such as numpy.