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

Oszkár Fehér
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Oszkár Fehér
Treehouse Project Reviewer

Again, i did in Pycharm and it's working and here doesen't let me to pass

I don't understand why

first_class.py
class Student:
    name = "Oszkar"

    def praise(self,name):
        self.name = name
        if self.name:
            return print("You're doing a great job "+name)
me = Student()
me.praise("Oszkar")
me.praise("Michael")

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Rayan! You're doing well, but keep in mind that these challenges are very exacting. Even code that is completely functional outside the challenge can cause the challenge to fail. It's always a good idea to try not to do anything not explicitly asked for.

The challenge says nothing of printing nor making an instance of the student. Also, the if statement is unnecessary. It simply wants you to define the method that returns a string with a congratulatory message.

My solution was 5 lines long and that's including a blank line. Try going through your code first and deleting things that aren't required by the challenge.

I think you can get it with these hints, but let me know if you're still stuck! :sparkles:

Hello Rayan! The task was to return the message (i.e. the string), but you've wrapped the string in a function call (print()), and returned this call. You can technically do this, it's syntactically correct, but the return value will simply be a None object in this case, because the print function doesn't have any return value (it's a function that only has a so-called "side effect"). And if you want your praise function to actually print the message when it is called, then just call the print function inside, without returning it.

Oszkár Fehér
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Oszkár Fehér
Treehouse Project Reviewer

I know Python just 6 days, i started from zero, i saw a few Python tutorials and from there i know, but i really like it i want to learn it. I learned also by myself Java, the basics, but i can build windows application with some graphics included. So that's why i am confused a little bit because there it was explained a little different(YouTube tutorials)

Ok, feel free to ask if you need some further clarification or have some specific question regarding the inner workings of Python then.