Complete the code to print each character in the string.
for char in [1]: print(char)
The string must be in quotes to be treated as a string. So "hello" is correct.
Complete the code to count how many times 'a' appears in the string.
count = 0 for char in "banana": if char == [1]: count += 1 print(count)
We check if the character equals the letter 'a' using single quotes.
Fix the error in the code to print each character in the string.
word = "code" for [1] in word: print(char)
The loop variable must be named 'char' to match the print statement.
Fill both blanks to create a dictionary with letters as keys and their uppercase as values.
result = { [1]: [2] for [1] in "abc" }Use 'char' as the loop variable and 'char.upper()' to get uppercase letters.
Fill all three blanks to create a dictionary with letters as keys, their index as values, but only for letters after 'b'.
result = { [1]: [2] for [1], [2] in enumerate("abcde") if [3] > 1 }Use 'letter' and 'index' from enumerate, and filter where index > 1.