Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
def count_occurrences(phrase: str, letter: str) -> int:
# write your code here
pass

Choose a reason for hiding this comment

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

The function is missing the required docstring. Please add the docstring provided in the task description to explain what the function does, its parameters, and what it returns.




counter = 0
for character in phrase:
if character.lower() == letter.lower():
counter += 1
return counter

Choose a reason for hiding this comment

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

While this loop correctly counts the occurrences, the task guidelines recommend a more Pythonic approach. Consider using the built-in lower() and count() string methods to achieve the same result in a single line without an explicit loop.

Loading