Removing punctuation/symbols from a list with Python except periods, commas
<p>In Python, I need to remove almost all punctuation from a list but save periods and commas. Should I create a function to do this or a variable? Basically I want to delete all symbols except letters (I've already converted uppercase letters to lowercase) and periods and commas (and maybe apostrophes). </p>

<pre><code>#Clean tokens up (remove symbols except ',' and '.')

def depunctuate()
   clean_tokens = []

   for i in lc_tokens:
       if (i not in [a-z.,])
       ...
</code></pre>

<p>You can build a set of unwanted punctuation from <a href="https://docs.python.org/2/library/string.html#string.punctuation" rel="nofollow"><code>string.punctuation</code></a> - which provides a string containing punctuation, and then use a <em>list comprehension</em> to filter out the letters contained in the set:</p>

<pre><code>import string

to_delete = set(string.punctuation) - {'.', ','} # remove comma and fullstop
clean_tokens = [x for x in lc_tokens if x not in to_delete]
</code></pre>

python normalization