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

Bummer: Didn't get the right string output. Got: dash for `S()`

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

    def __str__(self):
        self.pattern = ['.', '.', '.']
        for item in self.pattern:
            return 'dot'

    def __str__(self):
        self.pattern = ['_', '_', '_']
        for item in self.pattern:
            return 'dash'


class S(Letter):
    pass

1 Answer

Steven Parker
Steven Parker
231,236 Points

Here's some hints:

  • there should be only one "__str__" method
  • it should not assign any fixed pattern, but use the one already stored in the class
  • it needs to be able to convert any number of symbols to words in a string
  • the output will have as many words in it as the pattern has symbols
  • the words will be separated by hyphens ("-")
  • it will not "return" until the loop is completely finished

Thank you. I'm still getting an error for the code challenge

Steven Parker
Steven Parker
231,236 Points

If you've already handled all those hints, show your current code here so we can see what the issue is now.