Search code examples
pythonclasspython-2.7python-3.xattributeerror

How to apply python methods within a Class?


How can I use 'default' methods for example: string.lower() within a class?

This is the error I get:

result = text.lower.replace(string.punctuation, ' ').split(' ')
AttributeError: MyClass instance has no attribute 'lower'

Solution

  • You are missing one more set of ()

    result = text.lower().replace(string.punctuation, ' ').split(' ')
                       ^