Python Exercises: Match beginning and end of a word with a vowel
57. Word Starts & Ends with Vowel
From Wikipedia,
A vowel is a syllabic speech sound pronounced without any stricture in the vocal tract. Vowels are one of the two principal classes of speech sounds, the other being the consonant.
Write a Python program that checks whether a word starts and ends with a vowel in a given string. Return true if a word matches the condition; otherwise, return false.
Sample Data:
("Red Orange White") -> True
("Red White Black") -> False
("abcd dkise eosksu") -> True
Sample Solution:
Python Code:
import re
def test(text):
return bool(re.findall('[/^[aeiou]$|^([aeiou]).*\1$/', text))
text ="Red Orange White"
print("Original string:", text)
print("Check beginning and end of a word in the said string with a vowel:")
print(test(text))
text ="Red White Black"
print("\nOriginal string:", text)
print("Check beginning and end of a word in the said string with a vowel:")
print(test(text))
text ="abcd dkise eosksu"
print("\nOriginal string:", text)
print("Check beginning and end of a word in the said string with a vowel:")
print(test(text))
Sample Output:
Original string: Red Orange White Check beginning and end of a word in the said string with a vowel: True Original string: Red White Black Check beginning and end of a word in the said string with a vowel: False Original string: abcd dkise eosksu Check beginning and end of a word in the said string with a vowel: True
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python program to check each word in a string and return True if it starts and ends with a vowel.
- Write a Python script to filter a list of words, keeping only those that begin and end with a vowel, and then print the result.
- Write a Python program to scan a sentence and output all words that start and end with any of the vowels.
- Write a Python program to verify whether every word in a string starts and ends with a vowel and then return a boolean value.
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous Python Exercise: Convert a given string to snake case.
Next Python Exercise: Two following words begin and end with a vowel.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.