Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Trie:
- """Бор слов"""
- def __init__(self, word = None):
- self.trie = {"Root": {}}
- if word != None:
- Trie.add_word(word)
- def __repr__(self):
- return("Trie of words")
- def __str__(self):
- return("I'm going to do it later")
- def add_word(self, word):
- now = self.trie["Root"]
- for i in word:
- if(i not in now):
- now[i] = {}
- now = now[i]
- else:
- now = now[i]
- else:
- now["end"] = ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement