Dec-12-2021, 09:26 PM
(Dec-12-2021, 08:54 PM)snippsat Wrote: A more normal and standard way to do this menator01.
import random class Word: def __init__(self, word_list): self.word_list = word_list def get_word(self): words = random.choice(self.word_list) return words word_list = ['a', 'ranom', 'list', 'of', 'words'] word = Word(word_list) for w in range(5): print(word.get_word())
Output:words of of ranom words
True. My example was to initiate the class without setting the instance variable right away.
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags