6(iii)
Write a Python program to count the number of vowels in a given string. Your program should do the following:
- (a)Define a string.
- (b)Traverse the string and count the vowels (a, e, i, 0, u) using a loop.
- (c)Print the total count of vowels.
Show SolutionHide Solution↓
st = "Artificial Intelligence"
count = 0
for ch in st:
if ch in 'aeiouAEIOU':
count += 1
print("Total number of vowels:", count)
Total number of vowels: 10