From 3a6feba93af298491dbdf6db23fef0ee0e2bcb1b Mon Sep 17 00:00:00 2001 From: Maksym Lupekha <2627number2@gmail.com> Date: Wed, 7 Feb 2024 21:45:57 +0200 Subject: [PATCH] solution with one line code --- app/main.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/main.py b/app/main.py index 4cbde1f4..8b0f5717 100644 --- a/app/main.py +++ b/app/main.py @@ -14,9 +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 """ - count = 0 - - for char in phrase: - if letter.lower() in char.lower(): - count += 1 - return count + return phrase.lower().count(letter.lower())