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 trialsandeep Singh
381 PointsWhats missing !
Please help me with some coding instructions & please please need the explanation of the logic deployed by you
class Letter:
def __init__(self, pattern=None):
self.pattern = pattern
def __str__(self):
return str(pattern)
for i in pattern:
if pattern == "dot" or "dash":
dot = "."
dash = "-"
print dot
print dash
class S(Letter):
def __init__(self):
pattern = ['.', '.', '.']
super().__init__(pattern)
2 Answers
Ari Misha
19,323 PointsHiya Sandeep! There are few issues with your code, so instead of pointing out every issue , i'll just leave my code here for your reference so that you could find out issues in your code alright? Here ya go:
def __str__(self):
arg = []
for i in self.pattern:
if i == ".":
arg.append("dot")
elif i == "_":
arg.append("dash")
return("-".join(arg))
sandeep Singh
381 Pointswhy list been added
Ari Misha
19,323 PointsYou dont have to if you dont wanna! But this is one of many ways to do it and i'd say most simple one.