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


Nadia Hussein
Nadia Hussein
646 Points

I'm getting the correct output, but it is still saying incorrect output. Anyone have an idea?


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

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

    def __str__(self):
        output = ""
        for item in self.pattern:
            if item == '.':
                output += 'dot-'
            if item == '_':
                output += 'dash-'
        return output [:-1]

1 Answer

Leandro Inumerable
Leandro Inumerable
11,553 Points

Your code works only for the Letter S since your str method is written in the child class S and not the parent class Letter.

If you move the str method to the parent class, it will work for other classes that Treehouse might try to check it with.