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


I should be close

Need to see how to remove the last "-"

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

    def __str__(self):
        for item in self.pattern:
            if item == ".":
            elif item == "_":
        print(substr(str(self.morse)), 0, -1)

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

1 Answer

Steven Parker
Steven Parker
229,005 Points

You have a good idea, but there's a bit to do yet:

  • you need to initialize morse to an empty array in the method
  • morse doesn't need to be a class property, it can be a local variable
  • "else: continue" is not needed as that's the default behavior of a loop
  • you might use join to combine the array into a string (str might not do what you think)
  • if you join using "-" as the separator, you won't have any excess to remove
  • you need to return the final string, not print it

That last item may seem contrary to the instructions, you might want to report that as a bug in the instructions to Support.