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!
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
Morse code challenge - can't solve it!
I've been staring at this for a while now and have browsed other solutions within the Community pages but can't see what I've done wrong here.
I think continuing to stare at the code is unlikely to produce a different result so I could do with some help, please!
class Letter: def __init__(self, pattern=None): self.pattern = pattern def ___str___(self): output =  for c in self.pattern: if c == '.': output.append('dot') elif c == '_': output.append('dash') return "-".join(output) class S(Letter): def __init__(self): pattern = ['.', '.', '.'] super().__init__(pattern)
Steven Parker228,025 Points
Your code is fine.
You just have the wrong name for your method. You have "
___str___" (with 6 underscores), but the name should be "
__str__" (with 4 underscores).
That's very odd, though. In the IDE, there's two underscores each side so there must be some weird copy/paste issue that I created.
Thanks again - that'll give me something more interesting to stare at today!