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

morse code printer challenge python answer not working

I was doing this challenge called the morse code printer in oop python section and my code gives the proper output in the ide but i get a bummer message in the treehouse ide. Can I get some help to understand whats wrong with my code

 class Letter:
    def __init__(self,pattern = None):
        self.pattern = pattern
    def __str__(self):
        lis = []
        final = ''
        for x in self.pattern:
            if x == ".":
                lis.append("dot")
            if x == "_":
                lis.append("dash")
        return "-".join(lis)

2 Answers

Steven Parker
Steven Parker
243,318 Points

This code passes the challenge. :+1:

But what is shown here is not the whole challenge code. The initially provided code also contains a definition for a class named "S", which the validation uses to test your method.

Did you remove that part of the code?

oh woops, i did remove it by mistake, thanks for the answer