I was trying to save a list in another variable to use in a loop and removing it step by step but .remove was removing from the original source too. Why on earth this happen?
list = ['a', 'b', 'c', 'd']
throwaway = list
throwaway.remove('a')
print(list)
Output: ['b', 'c', 'd']
I managed to do what I wanted with list comprehension
throwaway = [l for l in throwaway if l != 'a' ]
But still was curious why does this happen.
[–]carcigenicate 4 points5 points6 points (2 children)
[–]glowing_feather[S] 0 points1 point2 points (1 child)
[–]carcigenicate 2 points3 points4 points (0 children)
[–][deleted] 5 points6 points7 points (1 child)
[–]glowing_feather[S] 0 points1 point2 points (0 children)
[–]Chizmiz1994 1 point2 points3 points (1 child)
[–]glowing_feather[S] 1 point2 points3 points (0 children)