Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Object-Oriented Python Instant Objects Your first method

python oop with kenneth

am failing to understand oop ,from the first two videos i have watched am totally lost,please helf

class Student:
    name = "Your Name"
    def praise(self) :
        return 'well done'.self
        return self.name

1 Answer

Steven Parker
Steven Parker
215,956 Points

Here's a few hints:

  • nothing named "def_str_" has been defined, and it's not valid definition syntax
  • the instructions only ask for a "praise" method, nothing else will be needed
  • a string has no "self" attribute
  • you can use concatenation ("+" operator) to build up a string using a variable
  • the syntax for a concatenated message might look like :point_right: 'well done ' + self.name