# This program looks through the dictionary file for words
# with many consecutive vowels.

def hasNVowels(s, n):
    # This returns True if string s has
    # n consecutive vowels
    longest = 0 # the length of the longest sequence of vowels
    current = 0 # the lenght of the current sequence of vowels
    for letter in  s:
        if letter.lower() in "aeiou":
            current = current + 1
            if current > longest:
                longest = current
        else:
            current = 0
    if longest >= n:
        return True
    else:
        return False

def ConsecutiveVowels(L, n ):
    # This prints all of the words in L that
    # have n consecutive vowels
    count = 0
    for word in  L:
        if hasNVowels(word, n):
            print(word)
            count = count + 1
    print( "I found %d words with %d consecutive vowels."%(count, n))
            
def main():
    F = open( "words25K.txt", "r")
    wordList = []
    for line in F:
        word = line.strip()
        wordList.append(word)
    done = False
    while not done:
        n = eval(input( "Who many consecutive vowels do you want? "  ))
        if n == 0:
            done = True
        elif n == 1:
            print( "no" )
        else:
            ConsecutiveVowels(wordList, n)



main()
