Skip to content

Commit 9a41dc4

Browse files
author
Karan Goel
committed
Count vowels done
1 parent 2a8b275 commit 9a41dc4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Text/count_vowels.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""
2+
Count Vowels - Enter a string and the program counts
3+
the number of vowels in the text. For added complexity
4+
have it report a sum of each vowel found.
5+
"""
6+
7+
string = raw_input('Enter a string: ').lower()
8+
9+
vowels = ['a', 'e', 'i', 'o', 'u']
10+
counts = dict(zip(vowels, [0, 0, 0, 0, 0]))
11+
12+
for vowel in counts:
13+
for char in string:
14+
if vowel == char:
15+
counts[vowel] += 1
16+
17+
print counts

0 commit comments

Comments
 (0)