Jun-03-2020, 08:05 PM
Create a function that counts the number of syllables a word has. Each syllable is separated with a dash -.
Examples
number_syllables("buf-fet") ➞ 2
number_syllables("beau-ti-ful") ➞ 3
number_syllables("mon-u-men-tal") ➞ 4
number_syllables("on-o-mat-o-poe-ia") ➞ 6
Notes
Don't forget to return the result.
If you get stuck on a challenge, find help in the Resources tab.
If you're really stuck, unlock solutions in the Solutions tab.
This is what I came up with so far:
Examples
number_syllables("buf-fet") ➞ 2
number_syllables("beau-ti-ful") ➞ 3
number_syllables("mon-u-men-tal") ➞ 4
number_syllables("on-o-mat-o-poe-ia") ➞ 6
Notes
Don't forget to return the result.
If you get stuck on a challenge, find help in the Resources tab.
If you're really stuck, unlock solutions in the Solutions tab.
This is what I came up with so far:
def number_syllables(word): return word.split("-") and word.count(word)