Hacking Secret Ciphers with Python

(Ann) #1
Chapter 10 – Programming a Program to Test Our Program 145

Remember that variables are like boxes that contain values. List variables don’t actually contain
lists at all, they contain references to lists. Here are some pictures that explain what happens in
the code you just typed in:


Figure 10-1. Variables do not store lists, but rather references to lists.

On the first line, the actual list is not contained in the spam variable but a reference to the list.
The list itself is not stored in any variable.


Figure 10-2. Two variables store two references to the same list.
Free download pdf