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

Frances Angulo
Frances Angulo
5,311 Points

Really discouraged with morse code challenge

This is the second challenge in a row where I have no idea where to start and when I search the help database, the posted answers have nothing to do with the recent content learned but more importantly, contain concepts that aren't covered in the material. I find this really discouraging and it's making the object oriented section extremely difficult to get through and I'm considering a switch to another learning platform.

morse.py
class Letter:
    def __init__(self, pattern=None):
        self.pattern = pattern
    def __str__(self):
        for char in self.pattern:
            if char == ".":  

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

my_try = S()
print(my_try.__str__())

1 Answer

Steven Parker
Steven Parker
231,275 Points

You seem off to a good start. What's left might be:

  • starting with an empty list variable
  • appending the word "dot" to the list when your test for "." is true
  • appending the word "dash" to the list otherwise
  • after the loop is done, joining the list into a string with "-" as a separator
  • then returning that final string

Does breaking it down like that help? I think you've probably seen examples of the individual tasks by now.