Complete the code to print each character in the string word using a for loop.
word = "hello" for [1] in word: print([1])
We use a variable name like char to represent each character in the string as we loop through it.
Complete the code to print the character at index 2 of the string word.
word = "world" print(word[1])
Indexing in strings starts at 0, so index 2 is the third character.
Fix the error in the code to print all characters of text using a while loop.
text = "data" i = 0 while i < len(text): print(text[1]) i += 1
To access characters by index, use square brackets with the index variable.
Fill both blanks to create a dictionary that maps each index of word to its character.
word = "code" index_map = { [1]: [2] for [1] in range(len(word)) }
We use i as the index and word[i] as the character at that index.
Fill all three blanks to create a list of uppercase characters from word that come after the letter 'a'.
word = "alphabet" result = [[1].upper() for [2] in word if [3] > 'a']
upper() on the character.We use char as the variable for each character in the string and check if it is greater than 'a'.