Cloud Stack Ninja

I know I'm close to figuring this out but I've been wracking my brain and can't think of what's going wrong here. I need to count the number of vowels in the array of nameList using the vowelList array, and currently it's outputting 22, which is not the correct number of vowels. Incidentally, 22 is double the length of the array nameList, but I can't see any reason what I wrote would be outputting double the array length. Any help would be appreciated. Not looking for the answer, for a nudge in the right direction.

nameList = [ "Euclid", "Archimedes", "Newton","Descartes", "Fermat", "Turing", "Euler", "Einstein", "Boole", "Fibonacci", "Nash"]
vowelList = ['A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U','u']

z=0
counter = 0
for k in nameList:
    i = 0
    for q in vowelList:
        counter+=nameList[z].count(vowelList[i])
        i+=1
    z=+1
print("The number of vowels in the list is",counter)


Read more here: https://stackoverflow.com/questions/64397809/counting-vowels-in-an-array-python

Content Attribution

This content was originally published by wombatpandaa at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: