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 trial

Python

I 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

Steven Parker
Steven Parker
229,744 Points

In 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.

youssef b10ta
youssef b10ta
Courses Plus Student 2,755 Points

im in the same position as RIP , without classes i could solve it but when it come to classes i kind stuck .

3 Answers

Agree 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
Steven Parker
229,744 Points

Just to point out once again, that's one solution and not the answer. :see_no_evil:

And FYI: Treehouse strongly discourages posting of explicit answers to quizzes or challenges without explanations, and will occasionally even redact the answers.

If I knew the Treehouse police were going to arrest me, I wouldn't have posted a solution lol

Steven Parker
Steven Parker
229,744 Points

At worst your post may get redacted, but they've been letting a lot slide since the staff was reduced last spring.

youssef b10ta
PLUS
youssef b10ta
Courses Plus Student 2,755 Points

i 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
Steven Parker
229,744 Points

If 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.

ok, thanks a lot. What do you mean it will get redacted?

Steven Parker
Steven Parker
229,744 Points

A 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.