From a70c16a39d522f0b46bbac89eeda1f00c1e1f0fe Mon Sep 17 00:00:00 2001 From: Kostya Date: Tue, 29 Oct 2024 20:10:57 +0200 Subject: [PATCH 1/3] Create file_new_for_test Create file_new_for_test --- file_new_for_test | 1 + 1 file changed, 1 insertion(+) create mode 100644 file_new_for_test diff --git a/file_new_for_test b/file_new_for_test new file mode 100644 index 00000000..359d41ba --- /dev/null +++ b/file_new_for_test @@ -0,0 +1 @@ +file_new_for_test From 727d0056f7791cfc5c7d4d097d4a89a96558f146 Mon Sep 17 00:00:00 2001 From: Kostya Mochulskiy Date: Tue, 29 Oct 2024 23:30:38 +0200 Subject: [PATCH 2/3] Solution --- app/main.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index 37b9f338..f7cd3051 100644 --- a/app/main.py +++ b/app/main.py @@ -1,3 +1,9 @@ def count_occurrences(phrase: str, letter: str) -> int: - # write your code here - pass + occurrences_count = 0 + for letter_phrase in phrase.lower(): + if letter_phrase == letter.lower(): + occurrences_count += 1 + return occurrences_count + + +print(count_occurrences("letter", "t")) From 7966d54957607535e0b44a12424511def0a25ebf Mon Sep 17 00:00:00 2001 From: Kostya Mochulskiy Date: Wed, 30 Oct 2024 14:35:51 +0200 Subject: [PATCH 3/3] Solution after changes --- app/main.py | 9 +-------- file_new_for_test | 1 - 2 files changed, 1 insertion(+), 9 deletions(-) delete mode 100644 file_new_for_test diff --git a/app/main.py b/app/main.py index f7cd3051..e613d444 100644 --- a/app/main.py +++ b/app/main.py @@ -1,9 +1,2 @@ def count_occurrences(phrase: str, letter: str) -> int: - occurrences_count = 0 - for letter_phrase in phrase.lower(): - if letter_phrase == letter.lower(): - occurrences_count += 1 - return occurrences_count - - -print(count_occurrences("letter", "t")) + return phrase.lower().count(letter.lower()) diff --git a/file_new_for_test b/file_new_for_test deleted file mode 100644 index 359d41ba..00000000 --- a/file_new_for_test +++ /dev/null @@ -1 +0,0 @@ -file_new_for_test