From 8f905bf23bc3080c50728d9499e76fe9984fd47d Mon Sep 17 00:00:00 2001 From: Egor Kostan <20955183+ikostan@users.noreply.github.com> Date: Tue, 17 Dec 2024 02:44:02 -0800 Subject: [PATCH] # Count letters in string --- kyu_6/count_letters_in_string/__init__.py | 1 + .../count_letters_in_string/count_letters_in_string.py | 6 ++++-- .../test_count_letters_in_string.py | 10 +++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/kyu_6/count_letters_in_string/__init__.py b/kyu_6/count_letters_in_string/__init__.py index e69de29bb2d..98c1fdb2c3b 100644 --- a/kyu_6/count_letters_in_string/__init__.py +++ b/kyu_6/count_letters_in_string/__init__.py @@ -0,0 +1 @@ +"""Count letters in string.""" diff --git a/kyu_6/count_letters_in_string/count_letters_in_string.py b/kyu_6/count_letters_in_string/count_letters_in_string.py index c92dfeb2db7..2bb80cdc585 100644 --- a/kyu_6/count_letters_in_string/count_letters_in_string.py +++ b/kyu_6/count_letters_in_string/count_letters_in_string.py @@ -1,5 +1,6 @@ """ -Solution for -> Count letters in string +Solution for -> Count letters in string. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -7,6 +8,8 @@ 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'. @@ -14,7 +17,6 @@ def letter_count(s: str) -> dict: :return: """ result: dict = {} - for char in s: if char.islower() and char not in result: result[char] = 1 diff --git a/kyu_6/count_letters_in_string/test_count_letters_in_string.py b/kyu_6/count_letters_in_string/test_count_letters_in_string.py index 27262ebe2bb..06b2d5dd04a 100644 --- a/kyu_6/count_letters_in_string/test_count_letters_in_string.py +++ b/kyu_6/count_letters_in_string/test_count_letters_in_string.py @@ -1,5 +1,6 @@ """ -Test for -> Count letters in string +Test for -> Count letters in string. + Created by Egor Kostan. GitHub: https://github.com/ikostan """ @@ -29,13 +30,12 @@ name='Source/Kata') # pylint: enable-msg=R0801 class CountLettersInStringTestCase(unittest.TestCase): - """ - Testing 'letter_count' function - """ + """Testing 'letter_count' function.""" def test_count_letters_in_string(self): """ - Testing 'letter_count' function + Testing 'letter_count' function. + :return: """ # pylint: disable-msg=R0801