python - Nested for loop to match vowels by iterating over strings and lists -


this question has answer here:

i trying loop on list, , match each character in list characters in string:

wordlist = ['big', 'cats', 'like', 'really'] vowels = "aeiou" count = 0  in range(len(wordlist)):     j in vowels:         if j in wordlist[i]:             count +=1             print(j,'occurs', count,'times') 

to return "a" occurs 2 times. each vowel not work. doing wrong?

try this:

wordlist = ['big', 'cats', 'like', 'really'] vowels = "aeiou"         v in vowels:     count = 0     word in wordlist:         if v in word:             count += 1     print(v,'occurs', count, 'times') 

results:

a occurs 2 times e occurs 2 times occurs 2 times o occurs 0 times u occurs 0 times 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -