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

Python

Need Help

What i am doing wrong?

morse.py
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, string):
        correct_list = []
        for i in string.split('-'):
            if i == 'dot':
                correct_list.append('.')
            else:
                correct_list.append('_')
        return cls(pattern=correct_list)

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

2 Answers

My bad - I corrected your indenting automatically - I couldn't help myself!!

You are missing a space before @classmethod - make sure it lines up with the line below it.

# not this
   @classmethod
    def from_string(cls, string):

# but this
    @classmethod
    def from_string(cls, string):

Steve.

Hi there,

Your code works fine for me so it seems you're not doing anything wrong! Is there something else you're asking about? If not, maybe copy your code, refresh the challenge - it should work fine.

Steve.

Refreshed several times.. Guess what A Bummer!!

Let me check again ... give me a minute ...