← Back to challenges

Spoonerisms

PythonHardstringsconditionsregex

Instructions

A spoonerism is when the first letters / sounds of two words are transposed onto one another. Create a function that takes a two-word string and performs a spoonerism on the phrase.

Examples

spoonerise("history lecture") ➞ "listory hecture"

spoonerise("loud noises") ➞ "noud loises"

spoonerise("chow mein") ➞ "mow chein"

spoonerise("innokodakademija rules!") ➞ "rinnokodakademija ules!"

Notes

  • Only two words will be parsed into the function. Don't worry about handling more than two.
  • You won't always just have to swap the first letters, take care to notice which letters have been switched in the examples (notice the difference between vowel-starting and consonant-starting words).
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.