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 trialcb123
Courses Plus Student 9,858 Pointsfirst_class: "Bummer! Exception: feedback() takes 1 positional argument but 2 were given"
Need help on interpreting how to fix my challenge issue. I am not sure how I am giving two positional arguments in my code
class Student:
name = "Your Name"
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)
def feedback(self):
if grade > 50:
praise()
else:
reassurance()
1 Answer
Alex Koumparos
Python Development Techdegree Student 36,887 PointsHi Cb123,
The error message is not very clear, but when it's talking about the number of positional arguments supplied (2), it is not referring to you calling a function with two positional arguments, but rather the behind-the-scenes code being run by Treehouse when it calls your function to test your code is supplying two arguments.
If we look again at the question text for the challenge we can see a clue to the solution:
"Alright, I need you make a new method named feedback. It should take an argument named grade."
The task is telling you to create a method that has two parameters: self
and grade
. When Treehouse calls your method it is providing a value for grade
and because you haven't implemented grade
it's causing the error message about you not having enough positional arguments in your method.
You should find that when you fix this you no longer get the error message you've described. However, you are still going to get a couple of other error messages. Look closely at the specification you were provided for clues on how to fix the remaining errors:
"You'll still need self in there, though. If grade is above 50, return the result of the praise method. If it's 50 or below, return the reassurance method's result."
Hopefully this helps, let me know if you are still stuck.
Cheers
Alex