Inserts a word into the trie. :type word: str :rtype: void
(self, word)
| 25 | self.root = TrieNode() |
| 26 | |
| 27 | def insert(self, word): |
| 28 | """ |
| 29 | Inserts a word into the trie. |
| 30 | :type word: str |
| 31 | :rtype: void |
| 32 | """ |
| 33 | node = self.root |
| 34 | for chars in word: |
| 35 | child = node.data.get(chars) |
| 36 | if not child: |
| 37 | node.data[chars] = TrieNode() |
| 38 | node = node.data[chars] |
| 39 | node.is_word = True |
| 40 | |
| 41 | def search(self, word): |
| 42 | """ |
no test coverage detected