Skip to content

Commit

Permalink
# Count letters in string
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Dec 17, 2024
1 parent 2fc9911 commit 8f905bf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions kyu_6/count_letters_in_string/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Count letters in string."""
6 changes: 4 additions & 2 deletions kyu_6/count_letters_in_string/count_letters_in_string.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
"""
Solution for -> Count letters in string
Solution for -> Count letters in string.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""


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
Expand Down
10 changes: 5 additions & 5 deletions kyu_6/count_letters_in_string/test_count_letters_in_string.py
Original file line number Diff line number Diff line change
@@ -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
"""
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8f905bf

Please sign in to comment.