Skip to content

Instantly share code, notes, and snippets.

@MohanSha
Created February 13, 2018 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MohanSha/c479cc4ad9bb112c39b8edbef51f9d09 to your computer and use it in GitHub Desktop.
Save MohanSha/c479cc4ad9bb112c39b8edbef51f9d09 to your computer and use it in GitHub Desktop.
Enter a string and the program counts the number of vowels in the text. For added complexity have it report a sum of each vowel found.
# Count Vowels
# Enter a string and the program counts the number of vowels in the text.
# For added complexity have it report a sum of each vowel found.
vowels = ['a', 'e', 'i', 'o', 'u']
counter = [0, 0, 0, 0, 0]
def count_vowels(string):
for i in range(0, 5):
counter[i] = string.count(vowels[i])
count_vowels(raw_input('String: '))
for i in range(0, 5):
print vowels[i] + ": " + str(counter[i])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment