Skip to content

Instantly share code, notes, and snippets.

@Codehunter-py
Last active November 2, 2023 11:07
Show Gist options
  • Save Codehunter-py/8f7690555c73858e1aaa760c8a5b3ab8 to your computer and use it in GitHub Desktop.
Save Codehunter-py/8f7690555c73858e1aaa760c8a5b3ab8 to your computer and use it in GitHub Desktop.
The multi_vowel_words function returns all words with 3 or more consecutive vowels (a, e, i, o, u).
import re
def multi_vowel_words(text):
pattern = r"(\w+[a,e,i,o,u]{3,}\w+)"
result = re.findall(pattern, text)
return result
print(multi_vowel_words("Life is beautiful"))
# ['beautiful']
print(multi_vowel_words("Obviously, the queen is courageous and gracious."))
# ['Obviously', 'queen', 'courageous', 'gracious']
print(multi_vowel_words("The rambunctious children had to sit quietly and await their delicious dinner."))
# ['rambunctious', 'quietly', 'delicious']
print(multi_vowel_words("The order of a data queue is First In First Out (FIFO)"))
# ['queue']
print(multi_vowel_words("Hello world!"))
# []
@saeedhisbani
Copy link

no need to insert , commas in [a,e,i,o,u] you may write it without commas

@Codehunter-py
Copy link
Author

@saeedhisbani Thank you for the detail. Appreciate that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment