комбинация join
и Counter
будет хорошим решением
listOfNames = ["Euclid", "Archimedes", "Newton", "Descartes", "Fermat", "Turing",
"Euler", "Einstein", "Boole", "Fibonacci", "Lovelace", "Noether",
"Nash", "Wiles", "Cantor", "Gauss", "Plato"]
r = "".join(listOfNames).lower()
from collections import Counter
sol = Counter(r)
print(sol)
выход
Counter({'e': 17, 'a': 9, 'n': 9, 'i': 8, 's': 8, 't': 8, 'o': 8, 'c': 7, 'l': 7, 'r': 7, 'u': 4, 'd': 3, 'h': 3, 'm': 2, 'w': 2, 'f': 2, 'g': 2, 'b': 2, 'v': 1, 'p': 1})
способ 2 с использованием while
# your code goes here
listOfNames = ["Euclid", "Archimedes", "Newton", "Descartes", "Fermat", "Turing",
"Euler", "Einstein", "Boole", "Fibonacci", "Lovelace", "Noether",
"Nash", "Wiles", "Cantor", "Gauss", "Plato"]
length = len(listOfNames)
count = 0
solution = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0,
'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0,
'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0,
'r': 0, 's': 0, 't': 0,
'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
while count<length:
for character in listOfNames[count]:
solution[character.lower()]+=1
count+=1
print(solution)
вывод
{'a': 9, 'b': 2, 'c': 7, 'd': 3, 'e': 17,
'f': 2, 'g': 2, 'h': 3, 'i': 8, 'j': 0,
'k': 0, 'l': 7, 'm': 2, 'n': 9, 'o': 8,
'p': 1, 'q': 0, 'r': 7, 's': 8, 't': 8,
'u': 4, 'v': 1, 'w': 2, 'x': 0, 'y': 0,
'z': 0}