From d49f9657895aaff9dd10eb6af637ccd459625147 Mon Sep 17 00:00:00 2001 From: Nikita Hodyna Date: Mon, 18 Aug 2025 17:15:44 +0200 Subject: [PATCH 1/3] Implement py-count-occurrences --- app/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index 37b9f338b..d7313fe2c 100644 --- a/app/main.py +++ b/app/main.py @@ -1,3 +1,3 @@ def count_occurrences(phrase: str, letter: str) -> int: - # write your code here - pass + string_lower = phrase.lower() + return string_lower.count(letter.lower()) From a005fecc341d7e1d049b353eba5bec091cbbfa50 Mon Sep 17 00:00:00 2001 From: Nikita Hodyna Date: Mon, 18 Aug 2025 17:49:56 +0200 Subject: [PATCH 2/3] Added docstring with explanation due to review --- app/main.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/main.py b/app/main.py index d7313fe2c..edd8a35ee 100644 --- a/app/main.py +++ b/app/main.py @@ -1,3 +1,13 @@ def count_occurrences(phrase: str, letter: str) -> int: + """ + Counts the number of times a given letter appears in a phrase, case-insensitively. + + Parameters: + phrase (str): The string in which to search for the letter. + letter (str): The letter to count within the phrase. + + Returns: + int: The number of occurrences of the letter in the phrase. + """ string_lower = phrase.lower() return string_lower.count(letter.lower()) From 739d2318c7fb4246ef562c17368c9b47129f4910 Mon Sep 17 00:00:00 2001 From: Nikita Hodyna Date: Wed, 20 Aug 2025 12:20:08 +0200 Subject: [PATCH 3/3] Fixed len of line number 3 --- app/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index edd8a35ee..4b9ddfe79 100644 --- a/app/main.py +++ b/app/main.py @@ -1,6 +1,6 @@ def count_occurrences(phrase: str, letter: str) -> int: """ - Counts the number of times a given letter appears in a phrase, case-insensitively. + Count occurrences of a letter in a phrase (case insensitive). Parameters: phrase (str): The string in which to search for the letter.