Monday, 25 January 2016

Program To Count Number Of Vowels

Hello friends,
Today I came with a new program to count number of vowels in a word or statement.
This program is very easy to understand and you can customize it to produce more   output.
So, let's start,

# This program is created by Sanjay Majhi.
def vowels(word1):
    vowels=consonant=0
    import string
# We have to lower case the word.
    word2=word1.lower()
    for i in word2:
        if i=="a" or i=="e" or i=="i" or i=="o" or i=="u":
            vowels+=1
        else:
            consonant+=1
    else:
        print 'Number of vowels is', vowels
        print "Number of consonants is",consonant
N=input("Enter how many times you want to enter;")
for i in range(N):
    word=raw_input("Enter a word:")
    vowels(word)

Just copy the code and paste it in python shell and run.
If you like the program do not forget to comment.
Get in touch with my blog to get more programs.

No comments:

Post a Comment