classWordDictionary:def__init__(self):""" Initialize your data structure here. """ self.trie ={}defaddWord(self,word:str) ->None: node = self.triefor char in word:if char notin node: node[char]={} node = node[char] node['$']=Truedefsearch(self,word:str) ->bool:defsearch_in_node(word,node) ->bool:for i, char inenumerate(word):if char =='.':for x in node:if x !='$'andsearch_in_node(word[i+1:], node[x]):returnTrueif char notin node:returnFalseelse: node = node[char]return'$'in nodereturnsearch_in_node(word, self.trie)# Your WordDictionary object will be instantiated and called as such:# obj = WordDictionary()# obj.addWord(word)# param_2 = obj.search(word)