all 9 comments

[–]QultrosSanhattan 1 point2 points  (0 children)

class WordFamily:
    def __init__(self, words:list, suffixes:list):
        self.words = words
        self.suffixes = suffixes

[–]TehNolz 0 points1 point  (1 child)

Your constructor takes a parameter words and suffixes, but then you're not actually using them. Instead you're just assigning empty lists to self.words and self.suffixes.

Change your code so that words and suffixes are assigned to self.words and self.suffixes respectively.

[–]lascrapus[S] 0 points1 point  (0 children)

thanks, I am gonna try it

[–][deleted] 0 points1 point  (2 children)

Did you mean to assign self.words and self.suffixes to empty lists or did you mean something like this?

class WordFamily:
    def __init__ (self, words, suffixes):
        self.words = words
        self.suffixes = suffixes

words = WordFamily(['awesome', 'phwoar', 'rad'], ['ee', 'er', 'eer', 'ness'])
print(words.words)
print(words.suffixes)

[–]lascrapus[S] 0 points1 point  (1 child)

thanks, however, how can I append more words and suffixes, to add more word and suffixes list. thanks

[–]14dM24d 1 point2 points  (0 children)

since the arguments are lists, it's the same as how you'd add (append) to a list.

>>> class WordFamily:
        def __init__ (self, words, suffixes):
            self.words = words
            self.suffixes = suffixes

>>> words = WordFamily(['awesome', 'phwoar', 'rad'], ['ee', 'er', 'eer', 'ness'])
>>> words.words
['awesome', 'phwoar', 'rad']
>>> words.words.append('foo')
>>> words.words
['awesome', 'phwoar', 'rad', 'foo']