A vowel is a speech sound or letter produced with relatively open airflow. For these Python exercises, the vowel set is the lowercase string “aeiou”; a word’s first character determines whether to use “a” or “an.” section 2.1.10 section 2.1.11
Classify a word’s initial character incrementally:
- Index the first character with word[0]; Python starts sequence indexes at zero. section 2.1.7
- Normalize case with word[0].lower() so uppercase input needs only one comparison. section 2.1.10
- Test membership with word[0].lower() in 'aeiou' instead of chaining five equality comparisons. section 2.1.10
- Choose an article with 'an' if the test is true, else 'a'; this deliberately ignores pronunciation exceptions such as “honor” and “union.” section 2.1.11
Choosing an article
For word = 'OCTOPUS', word[0].lower() is 'o', and 'o' in 'aeiou' is True, so article becomes 'an'. For “narwhal,” it becomes “a.” The result can be inserted into “Ahoy, Captain, an octopus off the larboard bow!” section 2.0 section 2.3.3
Replacing vowels
A second exercise accepts text and a validated -v or --vowel option, then replaces every vowel while preserving input case: “APPLES AND BANANAS” with -v i becomes “IPPLIS IND BININIS.” section 8.0 section 8.3.1
Use the lookout scenario to connect vowel classification with the concrete “a narwhal” and “an octopus” outputs. section 2.0


