I'm probably being really dumb here, but I can't figure out this error:
'str' object has no attribute 'punctuation'
This occurs on the line:
docLines[counter][counter2] = [(docLines[counter][counter2]).translate(None, string.punctuation)]
Where docLines[counter][counter2] is just a single word.
Any ideas where I'm going wrong with is line of code?
You've assigned a string (instance of str
) to a variable named string
. Rename the variable and the problem will go away.
To debug this, add print repr(string)
before the offending line and it will print a string instance. A number of such prints in various places in your module will help you discover where the name string
stopped referring to the string
module and started referring to a str
instance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With