You cannot pass anything by value in Python. If you want to make a copy of a
, you can do so explicitly, as described in the official Python FAQ:
b = a[:]
More Related Contents:
- How do I clone a list so that it doesn’t change unexpectedly after assignment?
- If in Python I put a list inside a tuple, can I safely change the contents of that list? [duplicate]
- Python – get unique and sorted values in list of lists [closed]
- Why is it string.join(list) instead of list.join(string)?
- Why does list.append evaluate to false in a boolean context? [duplicate]
- Finding and replacing elements in a list
- How to read a text file into a list or an array with Python
- How to sort two lists (which reference each other) in the exact same way
- Python list multiplication: [[…]]*3 makes 3 lists which mirror each other when modified [duplicate]
- Combining two sorted lists in Python
- Create an empty list with certain size in Python
- Case insensitive ‘in’
- Changing an element in one list changes multiple lists [duplicate]
- Alphabet range in Python
- Python list confusion [duplicate]
- How do I remove the first item from a list?
- How to frame two for loops in list comprehension python
- I want to exception handle ‘list index out of range.’
- How to convert nested list of lists into a list of tuples in python 3.3?
- Compact way to assign values by slicing list in Python
- Numpy individual element access slower than for lists
- list.extend and list comprehension [duplicate]
- Pairwise crossproduct in Python [duplicate]
- How to allow list append() method to return the new list
- how to convert list of dict to dict
- Pythonic Circular List
- TypeError: list indices must be integers or slices, not list
- Python and SQLite: insert into table
- Creating a list in Python with multiple copies of a given object in a single line
- How can I turn a flat list into a 2D array in python?