In python, how to import just words but not any punctuation from a .txt file?
<p>For example ,I have a txt file which content is:</p>

<blockquote>
  <p>Blockquote</p>
</blockquote>

<pre><code>star, year, op, ed
ad, ed, offer, year
</code></pre>

<blockquote>
  <p>Blockquote</p>
</blockquote>

<p>I want to import them and form a list which have each line as a sublist:
    [['star','year','op','ed'],['ad','ed','offer','year']]
So I use the command below:</p>

<blockquote>
  <p>Blockquote</p>
</blockquote>

<pre><code>list = []
with open ("file_name", 'r') as f:
    for line in f:
        split_line = line.split()
        list.append(split_line)
f.close()
</code></pre>

<p>But when I print the list, the result is:</p>

<blockquote>
  <p>Blockquote</p>
</blockquote>

<pre><code>[['star,','year,','op,','ed'],['ad,','ed,','offer,','year']]
</code></pre>

<p>So how can I get a list with only words but not any punctuations?</p>

<p>in split function try to give ", " as argument like this.</p>

<pre><code>split_line = line[:-2].split(", ")
</code></pre>

<p>Hope this helps.</p>

python python-3.x split