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

competent- fellow
competent- fellow
5,846 Points

Blocked at Morse Code (despite right output?)

I am stuck here. I get the following error message: “Didn’t get the right string ouput. Got: dot-dot-dot for ‘S()’”. Even though the output, according to the instructions, should be: “dot-dot-dot.” Any ideas what’s wrong?

morse.py
class Letter:
    def __init__(self, pattern=None):
        self.pattern = pattern

    def __str__(self):
        list_char = []
        for character in self.pattern:
            if character == ".":
                list_char.append("dot")
            elif character == "-":
                list_char.append("dash")
        return "-".join(list_char)

class S(Letter):
    def __init__(self):
        pattern = ['.', '.', '.']
        super().__init__(pattern)

1 Answer

Steven Parker
Steven Parker
229,708 Points

It looks like there's a bug in the error message. The validation did discover a legitimate issue, but it was probably testing a different character at the time.

The issue is that the code is translating hyphen ("-") into "dash", but it should be translating underscore ("_") instead.

If you want to report the error message as a bug, follow the instructions on the Support page.