title: For loop in python doesn't manipulate original objects, instead performs deep copy
body: <p>I'm doing a for loop over a list in Python, which to all of my knowledge should create a shallow copy of each element in the list. However, when I perform operations on elements, the changes aren't being reflected in the original list.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>interactions = f.readlines()
  for interaction in interactions:
      orig = interaction
      interaction = interaction.replace('.', '').replace(' ', '').strip('\n')
      if len(interaction) == 0:
          interactions.remove(orig)
  
      print(interactions)
  </code></pre>
  
  <p>The output of this operation given an initial list of <code>['. Bph\n', 'Cardiovascular\n', 'Diabetes\n', '. ']</code> is:</p>
  
  <pre><code>['. Bph\n', 'Cardiovascular\n', 'Diabetes\n', '. ']
  ['. Bph\n', 'Cardiovascular\n', 'Diabetes\n', '. ']
  ['. Bph\n', 'Cardiovascular\n', 'Diabetes\n', '. ']
  ['. Bph\n', 'Cardiovascular\n', 'Diabetes\n']
  </code></pre>
  
  <p>Even though when I follow the debugger I can see the correct operations being performed on <code>interaction</code> but the changes just arent being reflected in interactions. What am I doing wrong here?</p>