Search code examples
pythonnlp

How to calculate no. of complex words(Words containing more than two vowels) from a list of words in python?


I want to calculate the number of words containing more than two vowels from a list of words.


Solution

  • count = 0
    
    for myword in mylist:
        d = {}.fromkeys('aeiou',0)
        haslotsvowels = False
        for x in myword.lower():
            if x in d:
                d[x] += 1
        for q in d.values():
            if q > 2:
                haslotsvowels = True
        if haslotsvowels:
            count += 1
            
    print(count)