I am a beginner in Python, I cannot understand assignment operator clearly, for example:
list1 = [\"Tom\", \"Sam\", \"Jim\"]
list2 = list1
BrenBam has a good explanation of what is going on. deepcopy
a way to get around it:
>>> from copy import deepcopy
>>> list1 = ["Tom", "Sam", "Jim"]
>>> list2 = deepcopy(list1)
>>> list1[1] = "Sam's sister"
>>> list1
['Tom', "Sam's sister", 'Jim']
>>> list2
['Tom', 'Sam', 'Jim']
Good programming style will make it rare to have to actually use deepcopy
though.