Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Joel Tse
Joel Tse
2,906 Points

Can't pass the morse code challenge

The bummer shows me that I returned the right string for S() but I can't pass the challenge.

class Letter:
    def __init__(self, pattern=None):
        self.pattern = pattern
    def __str__(self):
        self.string = ''
        for item in self.pattern:
            if item  == '.':
                self.string += 'dot-'

            elif item == '_':
                self.string += 'dash-'

        self.string = self.string[0:-1:]
        return self.string

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

1 Answer

Alex Koumparos
Alex Koumparos
Python Development Techdegree Student 36,862 Points

You've modified the 'S' class. If you revert it back to the version supplied by Treehouse (just dot dot dot) then you'll pass the challenge.