Python Practice › String Programs › Program 66

Count and show vowels

EasyString Programs · 66 of 106

Write a Python program to count and display the vowels in a string.

Advertisement
Input
"welcome to Sqatools"
Output
['e', 'o', 'e', 'o', 'a', 'o', 'o'] 7

Approach

  1. Collect the vowels in a list.

Solution

Python
text = "welcome to Sqatools"vowels = [ch for ch in text if ch.lower() in "aeiou"]print(vowels, len(vowels))
Output
['e', 'o', 'e', 'o', 'a', 'o', 'o'] 7

Learn the concept

New to this topic? Read the lesson, then come back.

More string programs

← All 106 String Programs

Leave a Comment