We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent acb55d3 commit 9dad1bdCopy full SHA for 9dad1bd
1 file changed
count_vowels.py
@@ -0,0 +1,22 @@
1
+__author__ = 'Avinash'
2
+
3
4
+# Python3 program to count vowels in a string
5
6
+# string of vowels
7
+vowels = 'aeiou'
8
9
+input_str = input("Enter a string: ")
10
11
+# make input string case insensitive
12
+input_str = input_str.casefold()
13
14
+# make a dictionary with each vowel a key and value 0
15
+vowels_count = {}.fromkeys(vowels, 0)
16
17
+# count the number of each vowels
18
+for letter in input_str:
19
+ if letter in vowels_count:
20
+ vowels_count[letter] += 1
21
22
+print(vowels_count)
0 commit comments