Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Object-Oriented Python Instant Objects Your first method

Harold Thompson
Harold Thompson
18,157 Points

I am stuck on the first challenge of Object-Oriented Python.

What am I doing wrong?

first_class.py
class Student:
    self.name = 'Bob'

    def praise (self):

        return ('Your doing a great job {self.name}'.format(self.name)) 

1 Answer

Hi Harold. here's what your supposed to have. if you have questions feel free to consult me

class Student:
     name = "Fireball"
def praise (self):
      return "{} Your doing a great job!!".format(self.name)

you see you don't have to make the variable self.name the variable becomes self.name when you create it underneath the argument of self. you also don't have to put self.name in the text you normally just implement it in this way Harold Thompson

also when you are using return you normally don't need parenthesis. unless its for a add on such as .format, .append. etc.

Harold Thompson
Harold Thompson
18,157 Points

Thanks Christian Beckett and I appreciate the details with the answer. It worked.

No Problem my dude.