title: Changing element in a list
body: <p>So given a list, e.g.</p>
  
  <pre><code>lines = ['This', 'is', 'a', 'sentence.']
  </code></pre>
  
  <p>I need to remove all punctuation at the start and end of a word. In this case, the '.' from 'sentence.'.</p>
  
  <p>This is what I am using at the moment:</p>
  
  <pre><code>lines = line.strip().split()
  for l in lines:
      l = re.sub(r'^[^A-Za-z0-9]*|[^A-Za-z0-9]*$','', l)
  words.append(lines)
  </code></pre>
  
  <p>I know that the regex is working (through checking it by using <code>print(l)</code> in the loop), but when I print out lines (i.e. out of the loop), the punctuation is still there! What is wrong with my code.</p>
  
  <p>This is what should be appended to words:</p>
  
  <pre><code>lines = ['This', 'is', 'a', 'sentence']
  </code></pre>