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 trialMarcus Ducklow
1,978 PointsGot: <morse.S object at 0x7f573c41e0f0> for `S()`
Can someone tell me where the problem is?
class Letter:
def __init__(self, pattern=None):
self.pattern = pattern
def __str(self):
ThePattern=[]
for n in self.pattern:
if n == '.':
ThePattern.append('dot')
elif n == '_':
ThePattern.append('dash')
else:
ThePattern.append('')
return '-'.join(ThePattern)
class S(Letter):
def __init__(self):
pattern = ['.', '.', '.']
super().__init__(pattern)
1 Answer
Steven Parker
231,248 PointsJust one little issue. The method name here is "__str", but it should be "__str__" (two underscores on each side).
One other very minor point (it won't affect passing the challenge): the pattern should never contain anything but periods and underscores, so the final "else" isn't needed.
Marcus Ducklow
1,978 PointsMarcus Ducklow
1,978 PointsThat was it! I guess I just needed a second set of eyes.