Source code for kyu_6.count_letters_in_string.count_letters_in_string
# Created by Egor Kostan.
# GitHub: https://github.com/ikostan
# LinkedIn: https://www.linkedin.com/in/egor-kostan/
[docs]def letter_count(s: str) -> dict:
"""
Count lowercase letters in a given string
and return the letter count in a hash with
'letter' as key and count as 'value'.
:param s:
:return:
"""
result: dict = dict()
for char in s:
if char.islower():
if char not in result:
result[char] = 1
else:
result[char] += 1
return result