Complete the code to insert a word into a trie node.
node.children[[1]] = TrieNode()The variable char represents the current character in the word being inserted into the trie. We use it as the key to add a new child node.
Complete the code to check if a prefix exists in the trie.
if [1] not in node.children: return False
We check if the current character char of the prefix exists among the children of the current node.
Fix the error in the code to move to the next node during prefix search.
node = node.children[[1]]We update node to the child node corresponding to the current character char in the prefix.
Fill both blanks to create a dictionary comprehension that maps each word to its length if the word starts with 'pre'.
{word: [1] for word in words if word.[2]('pre')}The dictionary comprehension maps each word to its length using len(word). The condition uses word.startswith('pre') to filter words starting with 'pre'.
Fill all three blanks to create a dictionary comprehension that maps uppercase words to their lengths if the length is greater than 3.
{ [1]: [2] for [3] in words if len(word) > 3 }word.lower() instead of uppercase.The comprehension maps the uppercase version of each word to its length using len(word). The variable word iterates over the list words. The condition filters words longer than 3 characters.