Data Structures

Pointers

Lesson

In Python, Arrays store pointers to their data - they don't store raw data itself. It turns out that every data structure stores pointers to their data in Python (and most other modern programming languages). Everything's made up of pointers! Even variables are pointers in Python!

The amazing result of this is that whenever you write A = B, Python points A to the item at B. There are no exceptions. Here's an example where we run one line of code at a time, and we show you the picture you should have in mind as the code runs.

Note that as the code ran, we changed y, but x changed too! This is confusing behavior to beginners, but it's easy to understand once you know everything's made of pointers in Python, and A = B always points A to the item at B.

Mark as Completed:
Submits:
test
Test your code to get an output here!