Data Structures

Pointers

Lesson

We saw that Arrays store pointers to their data. It turns out that every data structure in Python uses pointers. Variables are also pointers in Python. There's a single fact that brings this all together:

When you write A = B, Python points A to B.

Here's an illustration of what happens as we run these lines of code:

Note that we changed y, but x changed! This strangeness would normally be confusing, but it's easy to understand as long as you know that variables are pointers, and A = B points A to B.

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