Write a Python program to count and display the vowels of a given text


This program is counting the number of vowels in a string "Tutor Joes". The string is assigned to the variable "val". Next, another string "aeiuoAEIOU" is assigned to the variable "vow". This string contains all the vowels, both lowercase and uppercase.

The code then creates a list "a" using a list comprehension that iterates through each character in the "val" string and only includes characters that are in the "vow" string. In other words, it only includes the vowels in the "val" string.

Finally, the program prints the vowels that were found in the "val" string using the "print" function with the message "Vowels Character :" followed by the list "a". It then prints the count of vowels using the "print" function with the message "Vowels Count :" followed by the length of the list "a".

Source Code

val = "Tutor Joes"
vow = "aeiuoAEIOU"
a=[c for c in val if c in vow]
print("Vowels Character :",a)
print("Vowels Count :",len(a))

Output

Vowels Character : ['u', 'o', 'o', 'e']
Vowels Count : 4


Example Programs