Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

completed the task , py-count-occurences #678

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
8 changes: 5 additions & 3 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def count_occurrences(phrase: str, letter: str) -> int:
Implement count_occurrences function:

It takes a phrase and a letter and calculates the number of times
the letter appears in the phrase. The function is case insensitive.
the letter appears in the phrase. The function is case-insensitive.

count_occurrences("letter", "t") == 2
count_occurrences("abc", "a") == 1
Expand All @@ -13,5 +13,7 @@ def count_occurrences(phrase: str, letter: str) -> int:
:param phrase: phrase to count in it
:param letter: letter to find occurrences of it
:return: count occurrences of letter in phrase
"""
# write your code here
"""""

return sum(1 for character in phrase
if character.lower() == letter.lower())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to use sum use count