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


Akshaan Mazumdar
Akshaan Mazumdar
3,787 Points

Code not working

Please check the @classmethod. Challenge is not passing. Thanks

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 == '.':
        return '-'.join(output)

    def from_string(cls,strx):
        for y in x:
            if y == "dash":


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

1 Answer

Steven Parker
Steven Parker
229,920 Points

You're close, but your method needs to create and return a new instance with the pattern loaded into it. So the final line of the method should be something like this:

        return cls(xx)

Then, the one other issue is that instead of a hyphen, a "dash" should be represented in the pattern as an underscore ("_").

Akshaan Mazumdar
Akshaan Mazumdar
3,787 Points

Thanks Steven Parker !! . Your answers have really helped me learn and finish Object Oriented Python quickly!!