Skip to content

Instantly share code, notes, and snippets.

@nitinbhojwani
Created January 6, 2016 17:41
Show Gist options
  • Save nitinbhojwani/cbbd0baa6afc31d4082e to your computer and use it in GitHub Desktop.
Save nitinbhojwani/cbbd0baa6afc31d4082e to your computer and use it in GitHub Desktop.
Gives vowel count of string entered. Accepted string-> without number i.e alphabets A-Z a-z and all symbo
# Calling
print 'allowed input - any string without number(s) i.e. (^[[\S|\s][\d+][\S|\s]])'
string_input = raw_input('Enter String: ')
# using regex to validate the input
import re
if re.search(r'\d+', string_input):
exit('error - string must not consist any number')
# list of accepted vowels
vowels = ['a','e','i','o','u','y']
char_list = list(string_input)
count = 0
for char in char_list:
if char.lower() in vowels:
count += 1
print count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment