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 trialRabih Atallah
3,405 Pointsidentation error
Please why I get the error message: indentation error def student
class Treehouse:
"""Methods related to Treehouse and student.
"""
def student(self, name):
"""Gives a pleasant message about the student."""
return '{} is a great Treehouse student!'.format(name)
1 Answer
Chris Freeman
Treehouse Moderator 68,454 PointsThe indention of an individual block of code must be consistant. The indention is set by the first line of the block. In your code, the first block statement is the doc-string comment (6 spaces). The function student()
is indented only 4 spaces. So either remove two space in front of the doc-string (preferred), or add two spaces in front of the student()
function.
class Treehouse:
"""Methods related to Treehouse and student. #<-- two leading spaces removed
""" #<-- two leading spaces removed
def student(self, name):
"""Gives a pleasant message about the student."""
return '{} is a great Treehouse student!'.format(name)
Edit: fixed student()
docstring indention
Rabih Atallah
3,405 PointsRabih Atallah
3,405 PointsThank you for your help Chris! I did it the way you suggested it's still not working which is really strange!
Chris Freeman
Treehouse Moderator 68,454 PointsChris Freeman
Treehouse Moderator 68,454 PointsRight, I missed another indention error. I updated my answer above to fix the docstring indention for
student()
. The docstring needs to be indented the same as thereturn
statement.Rabih Atallah
3,405 PointsRabih Atallah
3,405 PointsThank you Chris it worked!