If you want a shallow copy (elements aren’t copied) use:
lst2=lst1[:]
If you want to make a deep copy then use the copy module:
import copy
lst2=copy.deepcopy(lst1)
More Related Contents:
- Why is “1000000000000000 in range(1000000000000001)” so fast in Python 3?
- How to have one colorbar for all subplots
- unknown error: session deleted because of page crash from unknown error: cannot determine loading status from tab crashed with ChromeDriver Selenium
- How do I specify new lines on Python, when writing on files?
- How can I iterate through two lists in parallel?
- How to resolve TypeError: can only concatenate str (not “int”) to str [duplicate]
- First non-null value per row from a list of Pandas columns
- Selecting multiple slices from a numpy array at once
- How do I change the range of the x-axis with datetimes in matplotlib?
- Private members in Python
- Disable assertions in Python
- When do you use ‘self’ in Python?
- APT command line interface-like yes/no input?
- join two lists of dictionaries on a single key
- In Python, how do I iterate over a dictionary in sorted key order?
- shuffle string in python
- Difference between dict.clear() and assigning {} in Python
- Comparing floats in a pandas column
- Python – Converting XLSX to PDF
- Flattening a list recursively [duplicate]
- Environment Variables when script run by cron
- Why is `with open()` better for opening files in Python?
- Convert int to ASCII and back in Python
- NotImplementedError: Cannot convert a symbolic Tensor (2nd_target:0) to a numpy array
- How to upload multiple files in django rest framework
- Why is sin(180) not zero when using python and numpy?
- Creating a Python list comprehension with an if and break
- Python and 16 Bit Tiff
- Difference between “data” and “params” in Python requests?
- Why do I get an error “‘str’ object does not support item deletion” when trying to delete values from a JSON object?