Skip to content

Commit

Permalink
rewriten function using method count of string
Browse files Browse the repository at this point in the history
  • Loading branch information
vburkalo committed Jan 17, 2024
1 parent 1ec3d02 commit 90a1d86
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ 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 phrase.lower().count(letter.lower())


print(count_occurrences("ABC", "a"))

0 comments on commit 90a1d86

Please sign in to comment.