Lists are examples of objects. When you create an object and assign it to a variable, the variable only refers to the object and is not the object itself i.e. the variable points to that part of your computer's memory where the list is stored. Generally, you don't need to be worried about this, but there is a subtle effect due to references which you need to be aware of. This is demonstrated by the following example.
Example 9.6. Objects and references
#!/usr/bin/python # Filename : reference.py shoplist = ['apple', 'mango', 'carrot', 'banana'] mylist = shoplist # mylist is just another reference to the same list! del shoplist[0] # I purchased the first item, so I remove it from the list. print 'shoplist is', shoplist print 'mylist is', mylist # Notice that shoplist and mylist both print a list without the # 'apple' confirming that they refer to the same list object mylist = shoplist[:] # Obtain a full slice to make a copy del mylist[0] print 'shoplist is', shoplist print 'mylist is', mylist # Notice now that the two lists are different
$ python reference.py shoplist is ['mango', 'carrot', 'banana'] mylist is ['mango', 'carrot', 'banana'] shoplist is ['mango', 'carrot', 'banana'] mylist is ['carrot', 'banana']
Most of the explanation is available in the comments itself. What you need to remember is that if you want to make a copy of a list or such sequences and objects (not simple objects such as integers), then you have to use a slicing operation without numbers to make a copy. If you just assign the variable name to another variable name, both of them refer to the same object and not different objects.
Remember that an assignment statement for lists does not create a copy. You have to use the slicing operation to make a copy of the sequence.