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

Serhat Bolsu
Serhat Bolsu
15,328 Points

My solution is passing even though it is correct

Hi here is my solution

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

def __str__(self):
    result = []
    for i in self.pattern:
        if i == ".":
            result.append("dot")
        elif i == "_":
            result.append("dash")
    return "-".join(result)
morse.py
class Letter:
    def __init__(self, pattern=None):
        self.pattern = pattern

    def __str__(self):
        result = []
        for i in self.pattern:
            if i == ".":
                result.append("dot")
            elif i == "_":
                result.append("dash")
        return "-".join(result)

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

2 Answers

Eric M
Eric M
11,545 Points

I'm going to assume you meant that your code is correct but isn't passing the challenge.

A few of the Python challenges seem a little buggy in the code challenge interface, the morse one in particular, I had heaps of trouble getting a working solution to pass this. In the end I had to log out of Treehouse, close my browser, and then open up, log back in, come back to the challenge, and paste in my code.

Try just hitting the restart challenge button first, but if that doesn't work you might have to reboot the environment so to speak.

Eric M
Eric M
11,545 Points

p.s. your code passes on a copy paste

Serhat Bolsu
Serhat Bolsu
15,328 Points

TY. Thats exactly what I meant, I waas in very tired stage when I wrote the message. passed on it after copying other persons "same" code