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

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.

morse.py
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','_']
        super().__init__(pattern)

1 Answer

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,887 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.