← Back to challenges

Pronouncing A_E

PythonHardregexstrings

Instructions

Words with a_e in them (where the underscore represents any letters) are pronounced like ay_. Given a sentence, create a function which replaces all instances of a_e with a ay_.

Examples

pronounce_the_a_e("i want to bake a cake") ➞ "i want to bayk a cayk"

pronounce_the_a_e("cinnamon flakes") ➞ "cinnamon flayks"

pronounce_the_a_e("bravely escape and inflate") ➞ "brayvly escayp and inflayt"

pronounce_the_a_e("waste and taste") ➞ "wayst and tayst"

Notes

All words will be given in lowercase and without punctuation.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.