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 trialRIP' FINGALINS"""""""""
2,002 PointsI can't seem to do this. Can someone give me the answer?
I can't do this! Can someone help me with this. I have tired many different times and still haven't got it. Can someone give me the answer
youssef b10ta
Courses Plus Student 2,755 Pointsim in the same position as RIP , without classes i could solve it but when it come to classes i kind stuck .
3 Answers
Shaun Kelly
35,560 PointsAgree with Stephen above, however sometimes i feel it's easier to see a solution and learn from it that way.
class Letter:
def __init__(self, pattern=None):
self.pattern = pattern
def __str__(self):
hyphen_code = []
for i in self.pattern:
if i == '.':
hyphen_code.append("dot")
elif i == '_':
hyphen_code.append("dash")
return "-".join(hyphen_code)
class S(Letter):
def __init__(self):
pattern = ['.', '.', '.']
super().__init__(pattern)
Steven Parker
231,275 PointsJust to point out once again, that's one solution and not the answer.
And FYI: Treehouse strongly discourages posting of explicit answers to quizzes or challenges without explanations, and will occasionally even redact the answers.
Shaun Kelly
35,560 PointsIf I knew the Treehouse police were going to arrest me, I wouldn't have posted a solution lol
Steven Parker
231,275 PointsAt worst your post may get redacted, but they've been letting a lot slide since the staff was reduced last spring.
youssef b10ta
Courses Plus Student 2,755 Pointsi think @Shaun Kelly is right , sometimes solutions helps understand much better and i guess if Treehouse is against this , must be something wrong with the Team : Thanks for the help anyway :)
Steven Parker
231,275 PointsIf I understand their position (which is the same as mine) their interest is in providing the best learning experience, and one doesn't learn as much from an answer with no explanation as they would by being guided to solve the issue themselves with hints and explanations.
RIP' FINGALINS"""""""""
2,002 Pointsok, thanks a lot. What do you mean it will get redacted?
Steven Parker
231,275 PointsA redaction is when part of a posting (in this case, the code) is removed.
For example, see the answer to this previous question where a moderator redacted an explicit solution.
Steven Parker
231,275 PointsSteven Parker
231,275 PointsIn programming there is rarely only one exact "answer", and this challenge can be solved a number of ways.
Please give it your best "good faith" try and then show your code if you still have trouble. We can help you from there.