import random class WordList: def __init__(self, path): with open(path, "r", encoding="utf-8") as h: lines = h.readlines() self.words = [x.replace('\n', "") for x in lines] random.shuffle(self.words) def get_word(self): return self.words.pop(0)