DEV Community

RK
RK

Posted on

Total number of Vowels and Count of each individual vowel A,E,I,O,U in the string "Guvi Geeks Network Private Limited"

Define the input string

input_string = "Guvi Geeks Network Private Limited"

Convert the string to lowercase to make it case-insensitive

input_string = input_string.lower()

Initialize variables to store counts

total_vowels = 0
count_a = 0
count_e = 0
count_i = 0
count_o = 0
count_u = 0

Iterate through the characters in the string

for char in input_string:
if char in "aeiou":
total_vowels += 1
if char == "a":
count_a += 1
elif char == "e":
count_e += 1
elif char == "i":
count_i += 1
elif char == "o":
count_o += 1
elif char == "u":
count_u += 1

Display the results

print("Total Vowels:", total_vowels)
print("Count of 'A':", count_a)
print("Count of 'E':", count_e)
print("Count of 'I':", count_i)
print("Count of 'O':", count_o)
print("Count of 'U':", count_u)

Top comments (0)