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 Think i didn't get the question ?? i need more test cases to test

i Think i didn't get the question ?? i need more test cases to test

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

    def __str__(self):
        temp = ''
        for value in self.pattern:
            if value == '.':
                temp = temp + 'dot-'
            elif value == '-' or value == '(' or value == ')':
                temp = temp + 'dash-'
            else:
                temp = temp + value + '-'
        return ''.join(temp[:len(temp) - 1])


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

1 Answer

Steven Parker
Steven Parker
231,269 Points

You are really close! I just see two issues:

  • a "dash" in the pattern is represented by an underscore ("_") instead of a hyphen
  • you don't need to encode any symbols other than period (".") and underscore ("_")

The challenge won't actually notice if you fix the second issue. Fix the first one and you'll pass.