← Back to challenges

Amazing Alliteration

PythonHardstringsvalidation

Instructions

Alliteration refers to a sequence of words that begin with the same letter. For this exercise, a sentence is correctly alliterated if all words strictly greater than 3 characters begin with the same letter.

Examples

alliteration_correct("She swam to the shore.") ➞ True
# All words >= 4 letters long begins with "s"

alliteration_correct("Maybel manages money well.") ➞ False
# "well" does not begin with an "m"

alliteration_correct("He helps harness happiness.") ➞ True

alliteration_correct("There are many animals.") ➞ False

Notes

  • This is to allow for filler words such as "the", "to", "a", etc. - so words with three or fewer characters are not counted.
  • Punctuation does not count as part of a word's length.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Counting Adverbs