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 trialLuke Tate
Courses Plus Student 2,256 PointsWhy doesn't my string get approved by "Check Work"?
Whenever I type the second string into either the function, class or both, I always get an error? The preview never is available. What am I doing wrong?
1 Answer
Jeff Muday
Treehouse Moderator 28,720 PointsYou won't be able to see anything in the preview related to the docstrings. It is unfortunate that having the "Preview" option is there since it doesn't do much for this particular challenge.
Below is a solution to challenge 1 of 2 as an example of what the Challenge grader is looking for. You should have no trouble figuring out part 2 on your own. Note that both a class and its methods can have docstrings. These docstrings are immediately below the declaration line and can use three single-quotes or double-quotes for delimitation. They can be on multiple lines to support extended or complex strings.
DocStrings are an easy way to document code and many IDE (integrated development environments) and Documentation generation tools can use the Docstrings in ways to inform users of the intent of a class or method and valid parameters that are passed. Some documentation generators produce beautiful PDF and HTML documentation using DocStrings so it is really worthwhile investing the time to type these in if you think your code is destined for lots of reuse!
class Treehouse:
def student(self, name):
"""Gives a pleasant message about the student."""
return '{} is a great Treehouse student!'.format(name)
Joseph Yhu
PHP Development Techdegree Graduate 48,637 PointsJoseph Yhu
PHP Development Techdegree Graduate 48,637 PointsCould you provide us with your code?