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 Method Interactivity

Mark Nembhard
Mark Nembhard
1,387 Points

not much feedback on this one but please help on the if else steps to this quizz

I seem to have made an error in logic somewhere on this as i want to be able to choose one path if a value is over 50 or another if it is equal or below. All this using class and methods

first_class.py
class Student:

    name = "Mark"
    def feedback(self,grade):
        grade= 51
        if self.grade > 50:
             praise(self)
        else reassrance(self)


    def praise(self):
        return "You inspire me, {}".format(self.name)


    def reassurance(self):
        return "Chin up, {}. You'll get it next time!".format(self.name)

1 Answer

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

Hi there, Mark Nembhard ! There are a few things going on here.

  • First, add the code for your new method to the bottom of the file.
  • The feedback method takes a grade argument at the time it is called/executed. The class itself has no grade attribute so there is no such thing as self.grade here.
  • The else must be terminated with a colon and the following line indented under it.
  • You should be calling self.praise() and self.reassurance() without passing anything in
  • You are meant to return the strings produced by the praise and reassurance methods.
  • You have a typo in "reassurance" in your feedback method

Some pseudocode:

def feedback(self,grade):
       if grade > 50:
           #  return the string produced by the praise method called on self
        else: 
           # return the string produced by the reassurance method called on self

Hope this helps! :sparkles: