Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


plz help can't understand what to do to pass tihs question?

i'am trying to solve this from past 2 days but i'am unable to pass plz help me with your code ...

class Letter:
    def __init__(self, pattern=None):
        self.pattern = pattern

    def create_dash(cls,string):
        string_list = []
        str = string.split("-")
        for element in string_list:
            if element == "dash":

    def __iter__(self):
        yield from self.pattern

    def __str__(self):
        output = []
        for blip in self:
            if blip == '.':
        return '-'.join(output)

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

1 Answer

Steven Parker
Steven Parker
215,960 Points

You're getting close, but there's a few issues yet:

  • the new method is named "create_dash", but the instructions ask for one named "from_string"
  • the method is marked as "@from_string" but the instructions ask for a "@classmethod"
  • "dash" is converted to a hyphen ("-") but the instructions say to make them underscores ("_")
  • the method should return a new instance with the created pattern loaded

how to return a newinstance with the created pattern loaded

Steven Parker
Steven Parker
215,960 Points

Since the current class is passed in as "cls", it takes the pattern as an argument, and you've created the new pattern in "string_list":

        return cls(string_list)