Why loop over a string's characters directly instead of its indices — and how does `in` collapse a long chain of `or` checks into one line?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
word is given. Loop over its characters and count how many are vowels, treating the vowels as the letters in 'aeiou'. Assign the total to vowel_count.
Hint: the in keyword tests whether a character is one of a group of characters.
Characters as the loop sequence
Write for index in range(len(s)) with s[index] beside for char in s for the same i-or-u test on "sunny bright!", and record that both print the message twice.
Membership testing with in
Rewrite the condition as if char in 'iu' and record the chain of == comparisons joined by or that it stands in for.
The cheerleader spelling program
Write the loop over word that tests if w in ans against ans = "aefhilmnorsx" to pick "a" or "an", plus the for i in range(times) loop that repeats the word.
Counting unique letters with a seen string
Write if char not in seen: seen += char for s = "abca", trace seen as a, ab, abc, abc, and finish with print(len(seen)) giving 3.