need a help
can someone help on construction task python
class Letter: def __init__(self, pattern=None): self.pattern = pattern def from__string(cls, string): list = from_string("-") paattern =  for x in from_string: if x == "dash": pattern.append("-") return cls(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) class S(Letter): def __init__(self): pattern = ['.', '.', '.'] super().__init__(pattern)
Steven Parker195,089 Points
Here's a few hints:
- the entire method definition must be indented
- the instructions say this should be done with "\@classmethod"
- instead of "
from__string", the method name should be "
from_string" (just one underscore)
- this method shouldn't be recursive (should not call itself)
- you may want to "split" the string argument into a list
- the word "paatern" should be "pattern" (just one "a")
- since "list" is a keyword it's not a good choice for a variable name
- instead of a hyphen ("-"), a "dash" should be represented as an underscore ("_")
- the method should also convert "dot" into a pattern
- the "return" should not occur until the loop is finished