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 class

Challenge doesn't pass

Hello all,

My answer doesn't pass even though this works on my console. Since the code is really simple: what am I doing wrong here?

Cheers,

Lennert

first_class.py
class Student:
    name = "Joe"

me = Student()

print (me.name)

I also tried it by adding a function:

class Student:
    name = "Joe"

    def name_method(self):
        return self.name

me = Student()

print (me.name_method())

3 Answers

Ari Misha
Ari Misha
19,323 Points

Hiya Lennert! You code is right on point , i put your code in the editor and i reduced that tab between your print and parenthesis and it worked. Try this out:

class Student:
    name = "Joe"

me = Student()

print(me.name)
Chris Evergreen
Chris Evergreen
2,857 Points

Hi there!

Let's stick with the first version. The print function is actually print(), not print (). The space is not necessary. Otherwise, everything else in your code is more or less correct.

Best of luck!

Thanks, that helped! Got away with the space until now.... ;-)

Chris Evergreen
Chris Evergreen
2,857 Points

Well, looks like the Python Police got you good this time XD