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
George Clement2,816 Points
not sure what I'm missing but this works in my IDE >>> from noclass import S >>> S().from_string("dash-dot")
not sure why but this works in my IDE but not on the site
>>> from noclass import S >>> S().from_string("dash-dot") ['_', '.']
I must be missing something
class Letter: def __init__(self, pattern=None): self.pattern = pattern def __iter__(self): yield from self.pattern def __str__(self): output =  for blip in self: if blip == '.': output.append('dot') else: output.append('dash') return '-'.join(output) @classmethod def from_string(cls, str): output =  for blip in str.split("-"): if blip == "dot": output.append('.') if blip == "dash": output.append('_') return output class S(Letter): def __init__(self): pattern = ['.', '.', '.', '.'] super().__init__(pattern)
Chris FreemanTreehouse Moderator 68,388 Points
You are very close! The challenge asks that you return an instance of the class with the pattern extracted from the string. This can be done in your return statement:
Also, it is not a good practice to used reserved words or built-in functions names as variable names. Best to use “string” instead of
Post back if you need more help. Good luck!!!