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

d #1018

Open
Artgalst23 opened this issue Nov 20, 2023 · 0 comments
Open

d #1018

Artgalst23 opened this issue Nov 20, 2023 · 0 comments

Comments

@Artgalst23
Copy link

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.

count_occurrences("letter", "t") == 2
count_occurrences("abc", "a") == 1
count_occurrences("abc", "d") == 0
count_occurrences("ABC", "a") == 1

:param phrase: phrase to count in it
: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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant