That is because in python setting a variable actually sets a reference to the variable. Almost every person learning python encounters this at some point. The solution is simply to copy the list:
copy_list = org_list[:]
More Related Contents:
- What does this error mean ? "Expected an indented block" Python
- How to pivot a dataframe in Pandas? [duplicate]
- Why does (1 in [1,0] == True) evaluate to False?
- Selenium give file name when downloading
- What’s the best way to initialize a dict of dicts in Python? [duplicate]
- Normalize columns of pandas data frame
- Consistently create same random numpy array
- Plotting 3D Polygons in python-matplotlib
- How to load existing db file to memory in Python sqlite3?
- Is there a simple way to change a column of yes/no to 1/0 in a Pandas dataframe?
- Pretty-print a NumPy array without scientific notation and with given precision
- Why don’t these list operations return the resulting list?
- How to construct a set out of list items in python?
- How to pip or easy_install tkinter on Windows
- How to change legend size with matplotlib.pyplot
- Changing multiple column names but not all of them – Pandas Python
- Changing position of vertical (z) axis of 3D plot (Matplotlib)?
- create anaconda python environment with all packages
- How can I get the path to the %APPDATA% directory in Python?
- How to sort 2d array by row in python?
- Compress numpy arrays efficiently
- Matplotlib – logarithmic scale, but require non-logarithmic labels
- Error loading DLL in python, not a valid win32 application [duplicate]
- Element-wise string concatenation in numpy
- How can I choose a custom string representation for a class itself (not instances of the class)?
- How can I avoid “RuntimeError: dictionary changed size during iteration” error?
- Reading integers from binary file in Python
- Attempt to call an undefined function glutInit
- Creating and updating nested dictionaries and lists inside multiprocessing.Manager object
- Performing len on list of a zip object clears zip [duplicate]