Complete the code to convert the string to uppercase.
text = "hello world" result = text.[1]() print(result)
The upper() method converts all letters in the string to uppercase.
Complete the code to remove whitespace from both ends of the string.
text = " hello world " clean_text = text.[1]() print(clean_text)
The strip() method removes whitespace from both the start and end of the string.
Fix the error in the code to replace all spaces with underscores.
text = "hello world" new_text = text.[1](" ", "_") print(new_text)
The replace() method replaces all occurrences of the first string with the second string.
Fill both blanks to create a dictionary with words as keys and their lengths as values, only for words longer than 3 letters.
words = ["apple", "bat", "car", "dolphin"] lengths = {word: [1] for word in words if len(word) [2] 3} print(lengths)
Use len(word) to get the length of each word and filter words with length greater than 3 using >.
Fill all three blanks to create a dictionary with uppercase words as keys and their lengths as values, only for words longer than 4 letters.
words = ["apple", "bat", "car", "dolphin"] result = { [1]: [2] for word in words if len(word) [3] 4 } print(result)
Use word.upper() for keys, len(word) for values, and filter words with length greater than 4 using >.