There’s no way you can do that changing only that line. You can do:
a = [1]
b = a
a[0] = 2
b[0]
That creates a list, assigns the reference to a, then b also, uses the a reference to set the first element to 2, then accesses using the b reference variable.
More Related Contents:
- Are Python variables pointers? Or else, what are they?
- Simulating Pointers in Python
- Python & Ctypes: Passing a struct to a function as a pointer to get back data
- Why does using multiplication operator on list create list of pointers? [duplicate]
- How to pass a 2d array from Python to C?
- How to change the location of the pointer in python?
- Wrapping a pre-initialized pointer in a cython class
- What is Perl's equivalent of Python's time.time()? [closed]
- The letter ‘n’ is invalid syntax in Python? [closed]
- How to specify multiple return types using type-hints
- join list of lists in python [duplicate]
- How can I convert radians to degrees with Python?
- Extending list returns None [duplicate]
- Define css class in django Forms
- How do I add default parameters to functions when using type hinting?
- Spark union of multiple RDDs
- Downloading and unzipping a .zip file without writing to disk
- Convolving image with kernel in Fourier domain
- How can I loop over entries in JSON?
- How to create a file name with the current date & time in Python?
- How can I create a full path to a file from parts (e.g. path to the folder, name and extension)?
- Regexp to remove specific number of occurrences of character only
- QuerySet, Object has no attribute id – Django
- Can I somehow “compile” a python script to work on PC without Python installed?
- ValueError: Input 0 is incompatible with layer lstm_13: expected ndim=3, found ndim=4
- Django Multiple Databases – relation does not exist; LINE 1: SELECT COUNT(*) AS “__count” FROM
- How to document default None/null in OpenAPI/Swagger using FastAPI?
- How to create 3D scatter animations
- How to measure download speed and progress using requests?
- Python: Return 2 ints for index in 2D lists given item