File tree Expand file tree Collapse file tree 1 file changed +5
-10
lines changed
Expand file tree Collapse file tree 1 file changed +5
-10
lines changed Original file line number Diff line number Diff line change 11def count_occurrences (phrase : str , letter : str ) -> int :
22 """
3- Counts the number of times a specific letter appears in a phrase,
4- ignoring case sensitivity.
5-
6- The function uses Python's built-in string methods for conciseness
7- and efficiency.
8-
9- :param phrase: The input string to search within.
10- :param letter: The single-character string to count occurrences of.
11- :return: The total count of the letter in the phrase as an integer.
3+ Count occurrences of a letter in a phrase (case insensitive).
4+ :param phrase: The phrase to search within.
5+ :param letter: The letter to count occurrences of.
6+ :return: The number of occurrences of the letter in the phrase.
127 """
138
149# First, convert the phrase and the search letter to lowercase.
@@ -18,4 +13,4 @@ def count_occurrences(phrase: str, letter: str) -> int:
1813
1914# Use the built-in .count() method
2015
21- return phrase_lower .count (letter_lower )
16+ return phrase_lower .count (letter_lower )
You can’t perform that action at this time.
0 commit comments