Python Exercises: Extract the first n number of vowels from a string
Extract Specified Vowels
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 to extract the first specified number of vowels from a given string. If the specified number is less than the number of vowels present in the string then display "n is less than the number of vowels present in the string".
Sample Data:
("Python", 2) -> "n is less than number of vowels present in the string."
("Python Exercises", 3) -> "oEe"
("aeiou") -> "AEI"
Sample Solution-1:
Python Code:
Sample Output:
Original string and number: Python , 2 Extract the first n number of vowels from the said string: n is less than number of vowels present in the string. Original string and number: Python Exercises , 3 Extract the first n number of vowels from the said string: oEe Original string and number: AEIOU , 3 Extract the first n number of vowels from the said string: AEI
Flowchart:
Sample Solution-2:
Python Code:
Sample Output:
Original string and number: Python , 2 Extract the first n number of vowels from the said string: n is less than number of vowels present in the string. Original string and number: Python Exercises , 3 Extract the first n number of vowels from the said string: oEe Original string and number: AEIOU , 3 Extract the first n number of vowels from the said string: AEI
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python program to find all unique pairs of integers in a list that have an absolute difference of three, sorted by their first element.
- Write a Python program to count the number of pairs in a list that differ by exactly three.
- Write a Python program to identify and return pairs of numbers that differ by three, ignoring the order of elements.
- Write a Python program to find all pairs of integers with a difference of three and return them as a list of tuples sorted in ascending order.
Go to:
Previous Python Exercise: Sum of missing numbers of a list of integers.
Next Python Exercise: Find all pairs of that differ by three in a list.
Python Code Editor:
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.