Python altering list item in iteration
<p>I am trying to get this python code to get rid of punctuation marks associated with words and count the unique words. For some reason it's still counting both "hello." and "hello". Any help would be most appreciated. </p>

<pre><code>def word_distribution(words):
            word_dict = {}
            words = words.lower()
            words = words.split()
            for word in words:
                if ord('a') &lt;= ord(word[-1]) &lt;= ord('z'):
                    pass
                elif ord('A') &lt;= ord(word[-1]) &lt;= ord('Z'):
                    pass
                else: 
                    word[:-1]
            word_dict = {word:words.count(word)+1 for word in set(words)}
            return(word_dict)
</code></pre>

<p>You are making it too complicated, as Sohier Dane mentioned in the comments you can make use of the other post to remove punctuation and simplify the script to:</p>

<pre><code>import string
def word_distribution(words):
    words = words.translate(None, string.punctuation).lower()
    d = {}
    for w in words.split():
        if w not in d.keys():
            d[w] = 1
        else:
            d[w] += 1   
    return d
</code></pre>

<p>Results:</p>

<pre><code>&gt;&gt;&gt; x='Hello My Name Is hello.'
&gt;&gt;&gt; print word_distribution(x)  
&gt;&gt;&gt; {'is': 1, 'my': 1, 'hello': 2, 'name': 1}
</code></pre>

python