Robotics & Artificial Intelligence

Write a Python program to count the number of vowels in a given string. Your program should do the following:

  1. Define a string.
  2. Traverse the string and count the vowels (a, e, i, 0, u) using a loop.
  3. Print the total count of vowels.

Python String Manipulation

1 Like

Answer

st = "Artificial Intelligence"
count = 0
for ch in st:
    if ch in 'aeiouAEIOU':
        count += 1
print("Total number of vowels:", count)

Output

Total number of vowels: 10

Answered By

3 Likes


Related Questions