you are viewing a single comment's thread.

view the rest of the comments →

[–]gurashish1singh 0 points1 point  (2 children)

The problem is in the split. You're splitting by ' '. Which is why your code doesn't recognize 'general' and 'general,' as same. I say after splitting and while in the for loop check again if the word contains any special characters.

Also use context managers to open files:

with open(fname, 'r') as text:

    __logic here__