How can I travel through the words of a file in PYTHON?
<p>I have a file .txt and I want to travel through the words of it. I have a problem, I need to remove the punctuation marks before travelling through the words. I have tried this, but it isn't removing the punctuation marks.</p>

<pre><code>file=open(file_name,"r")
for word in file.read().strip(",;.:- '").split():
     print word
file.close()
</code></pre>

<p>I would remove the punctuation marks with the <code>replace</code> function after storing the words in a list like so:</p>

<pre><code>with open(file_name,"r") as f_r:
    words = []
    for row in f_r:
        words.append(row.split())
punctuation = [',', ';', '.', ':', '-']
words = [x.replace(y, '') for y in punctuation for x in words]
</code></pre>

python python-2.7 text punctuation