Welcome to the Treehouse Community
Looking to learn something new?
construction zone help
I do not know what did I did wrong it says that i didn't get the right pattern, can someone give me some hints of what am I doing wrong ? Thanks for your help !
class Letter: def __init__(self, pattern=None): self.pattern = pattern def __iter__(self): yield from self.pattern def __str__(self): output =  for blip in self: if blip == '.': output.append('dot') else: output.append('dash') return '-'.join(output) @classmethod def from_string(cls, strings): regular_pattern =  strings = strings.split("-") for dash_dot in strings: if dash_dot == ".": regular_pattern.append("dot") elif dash_dot == "-": regular_pattern.append("dash") return cls(regular_pattern) class S(Letter): def __init__(self): pattern = ['.', '.', '.'] super().__init__(pattern)
Steven Parker216,012 Points
This method is intended to look for "dot" and "dash" tokens in a string and convert them into a pattern made of period (".") and underscore ("_") elements.
But right now, its doing the opposite — looking for pattern elements and converting them to the words.
This is becoming frustrating, I am really sorry for bothering you Steven but I dont get why is it holding me back on these simple mistakes, btw you are awesome,stay safe in these difficult time wherever you may be !!!
@classmethod def from_string(cls, strings): dash_dot_pattern =  strings = strings.split("-") if strings == "dot": dash_dot_pattern.append(".") elif strings == "dash": dash_dot_pattern.append("_") return cls(dash_dot_pattern)
Oh sorry, it's the same code as the above one but I changed the hyphen into a underscore, still says it gives the wrong result....