How can Python simulate pointers given that it does not have traditional pointers like PHP or C++?

Hi Keerti,

You can’t achieve the desired behavior by modifying only that line. However, you can simulate python pointers using a list.

Here’s how:

a = [1]
b = a
a[0] = 2
print(b[0])

In this example, a is a reference to a list. When you assign b = a, both a and b point to the same list object in memory.

Modifying a[0] will also update b[0] because both variables reference the same list.