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 trialDaniel Bourke
3,870 PointsCan't seem to get the right output for Morse.py
Hey guys, I've been on this challenge for a while now and can't seem to get the right output.
I read through some community answers and mine is practically the same as some others that have passed.
Can anyone spot where I've gone wrong?
Thank you!
class Letter:
def __init__(self, pattern=None):
self.pattern = pattern
def __str__(self):
output = []
for i in self.pattern:
if i == '.':
output.append('dot')
elif i == '-':
output.appent('dash')
return "-".join(output)
class S(Letter):
def __init__(self):
pattern = ['.', '.', '.']
super().__init__(pattern)
Ps, if anyone could show me how to properly call this in the workspace so I could test it myself that would also be great! I've tried a few combinations I found on Stack Overflow but I don't know how right they are.
1 Answer
Steven Parker
231,261 PointsBe careful about testing a challenge in an external REPL.
If you have misunderstood the challenge, it's also very likely that you will misinterpret the results.
The instructions say that your method should "return... "dash" for every "_" (underscore)", but instead of testing for underscores, your code tests for hyphens ("-").
Also, I suspect your testing did not involve any hyphens, because when adding a "dash" to the list you wrote "appent" (with a "t") instead of "append" (with a "d").
Daniel Bourke
3,870 PointsDaniel Bourke
3,870 PointsThank you Steven!
I had to check what REPL meant but I totally agree.
I should've tried reading through the instructions a couple more times...