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 trialGarrett Stubblefield
6,674 PointsThis question is very confusing and I don't understand what is supposed to be returned or where
I do not understand the question
class Letter:
def __init__(self, pattern=None):
self.pattern = pattern
def __str__(self, pattern):
s = "-"
for pat in pattern:
if pat == '.':
return "dot"
if pat == '_':
return "dash"
return(s)
class S(Letter):
def __init__(self):
pattern = ['.', '.', '.']
super().__init__(pattern)
1 Answer
Steven Parker
231,269 PointsThe patterns are stored with single-character symbols (periods and underscores). The challenge asks you to create a new method that will translate that pattern into a string made up of the words "dot" and "dash" separated by hyphens.
It looks like you already have the right idea, but there's a bit of code needed yet and a few issues to fix. For one thing, you won't want to return until the loop is finished converting every element.