I am currently writing a program but came across an error in the code. I got it down to this:
This is the basis of the problem:
original_list = ["a","b","c","d","e","f","g","h","i","j"]
value = "a"
new_list = original_list
print(original_list)
new_list.pop(new_list.index(value))
print(original_list)
print(new_list)
I would expect this to output:
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
['b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
But instead it gives this, where the value "a" has been removed from the original list:
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
['b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
['b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
I cannot seem to figure out why, does anyone know?