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 trialsachin prasad
1,564 PointsGetting this error Exception: argument of type 'NoneType' is not iterable Not sure whats wrong here.
What am i doing wrong here? Exception: argument of type 'NoneType' is not iterable
I wish there was more explanation on when to use self and when not to use self.
class Student:
name = "Sachin"
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, grade):
if grade > 50:
self.praise()
else:
self.reassurance()
1 Answer
Micah Hack
12,902 PointsHello Sachin,
You're very close. You have the right idea. The self in your method calls is correct. The purpose of self is tell your class where to find the method you are calling. Your feedback method is calling praise and reassurance, but you have not specified it to do anything with the results.
I believe you are receiving the "'NoneType' object is not iterable error", because the value of the data is "None" due to it not being returned to the method.
In short all you need to do is "return" the result of the praise method as well as "return" the reassurance method's result.
I hope this helps. This is my first time attempting to answer a question, lol!
sachin prasad
1,564 Pointssachin prasad
1,564 PointsThank you Micha, That helped and fixed my issue.