Created
January 6, 2016 17:41
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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