From b7ec3af1983db468a1ae902da9bf563acc105e29 Mon Sep 17 00:00:00 2001 From: Matvii Safonov Date: Mon, 23 Sep 2024 08:38:16 +0300 Subject: [PATCH 1/3] Solution --- app/main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 4ccbb02b..62c80aac 100644 --- a/app/main.py +++ b/app/main.py @@ -14,4 +14,8 @@ def count_occurrences(phrase: str, letter: str) -> int: :param letter: letter to find occurrences of it :return: count occurrences of letter in phrase """ - # write your code here + counter = 0 + for char in phrase: + if char.lower() == letter.lower(): + counter += 1 + return counter From 54f3e92e07caabb8f0b723a2beae19c9083e4547 Mon Sep 17 00:00:00 2001 From: Matvii Safonov Date: Mon, 23 Sep 2024 12:23:15 +0300 Subject: [PATCH 2/3] Solution --- app/main.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/main.py b/app/main.py index 62c80aac..559c582f 100644 --- a/app/main.py +++ b/app/main.py @@ -14,8 +14,4 @@ def count_occurrences(phrase: str, letter: str) -> int: :param letter: letter to find occurrences of it :return: count occurrences of letter in phrase """ - counter = 0 - for char in phrase: - if char.lower() == letter.lower(): - counter += 1 - return counter + return sum(1 for char in phrase if char.lower() == letter.lower()) From 5e4e76111185a7adff36f1e03bf0005e7b667796 Mon Sep 17 00:00:00 2001 From: Matvii Safonov Date: Mon, 23 Sep 2024 13:23:28 +0300 Subject: [PATCH 3/3] Solution --- app/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 559c582f..8b0f5717 100644 --- a/app/main.py +++ b/app/main.py @@ -14,4 +14,4 @@ def count_occurrences(phrase: str, letter: str) -> int: :param letter: letter to find occurrences of it :return: count occurrences of letter in phrase """ - return sum(1 for char in phrase if char.lower() == letter.lower()) + return phrase.lower().count(letter.lower())