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 trialRichard Li
9,751 Pointsclassmethod challenge - the out put seems legit but it cannot pass the check
here is my code:
@classmethod
def from_string(cls, string):
result = []
string = string.split("-")
for i in string:
if i == "dash":
result.append("_")
elif i == "dot":
result.append(".")
return cls(result)
and below is the outbput:
>>> import classmethods
>>> a = classmethods.Letter.from_string("dot-dash-dot")
>>> a
<classmethods.Letter object at 0x7efcaf8963c8>
>>> str(a)
'dot-dash-dot'
>>> print(a)
dot-dash-dot
>>> for i in a:
... print(i)
...
.
_
.
str, iter all seems work, so the from_string does return a Letter object with the string's content.. But it cannot pass the check. What am I doing wrong here! please check!
1 Answer
Steven Parker
231,261 PointsIt looks OK to me, so I pasted the code directly into the challenge and it passed!
Try again?