Source code for kyu_6.count_letters_in_string.count_letters_in_string

"""
Solution for -> Count letters in string.

Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""


[docs] def letter_count(s: str) -> dict: """ Letter count. 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 = {} for char in s: if char.islower() and char not in result: result[char] = 1 else: result[char] += 1 return result