Complete the code to find if the substring exists in the main string.
if "needle" [1] "haystack": print("Found")
The keyword in checks if one string is inside another.
Complete the code to get the starting index of the substring in the main string.
index = "haystack".[1]("needle")
The find method returns the first index of the substring or -1 if not found.
Fix the error in the code to correctly check if the substring is not in the main string.
if "needle" [1] "haystack": print("Not found")
The not in keyword checks if a substring is absent from a string.
Fill both blanks to create a dictionary comprehension that maps words to their lengths only if the length is greater than 3.
{word: [1] for word in words if [2] > 3}The comprehension maps each word to its length using len(word), and filters words with length greater than 3.
Fill all three blanks to create a dictionary comprehension that maps uppercase words to their lengths only if the length is less than 5.
{ [1]: [2] for word in words if [3] < 5 }The comprehension uses word.upper() as keys, maps to len(word), and filters words with length less than 5.