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


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
228,001 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
228,001 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)