Computer Science
Write a program to count the number of each vowel in a given string.
Python
Python String Manipulation
4 Likes
Answer
input_string = input("Enter a string: ")
vowel_count = {'a': 0, 'e': 0, 'i': 0, 'o': 0, 'u': 0}
input_string = input_string.lower()
for char in input_string:
if char in vowel_count:
vowel_count[char] += 1
print("Vowel counts:", vowel_count)Output
Enter a string: The quick brown fox jumps over the lazy dog.
Vowel counts: {'a': 1, 'e': 3, 'i': 1, 'o': 4, 'u': 2}
Answered By
1 Like
Related Questions
Write a script to partition the string 'INSTITUTE' at the occurrence of letter 'T'.
What will be the output of the following programming code?
str = "My Python Programming" print (str[-5:-1]) print (str[1:5]) print (str[:-4]) print (str[0:]) print (str[:13-4]) print (str[:3])Write a program that reads a line, then counts how many times the word 'is' appears in the line and displays the count.
Write a program to remove 'i' (if any) from a string.