Complete the code to find the length of the list.
my_list = [1, 2, 3, 4] length = [1](my_list) print(length)
The len() function returns the number of items in a list.
Complete the code to get the length of the string.
word = "hello" word_length = [1](word) print(word_length)
The len() function works for strings to count characters.
Fix the error in the code to correctly get the length of the tuple.
my_tuple = (1, 2, 3) length = [1](my_tuple) print(length)
The len() function works for tuples to count elements.
Fill both blanks to create a dictionary with words as keys and their lengths as values for words longer than 3 letters.
words = ["apple", "bat", "car", "door"] lengths = { [1]: [2] for word in words if len(word) > 3 }
word.upper() or word.lower() as keys instead of the original word.The dictionary comprehension uses the word as the key and its length as the value.
Fill all three blanks to create a dictionary with uppercase words as keys and their lengths as values for words longer than 3 letters.
words = ["tree", "sun", "flower", "sky"] lengths = { [1]: [2] for word in words if len(word) [3] 3 }
The dictionary comprehension uses the uppercase word as the key, the length as the value, and filters words longer than 3 letters.