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
8 changes: 6 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
def count_occurrences(phrase: str, letter: str) -> int:

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. Task descriptions often include specific docstrings that need to be added to explain the function's purpose, parameters, and what it returns.

# write your code here
pass
result = 0
for letters in phrase:
if letters.lower() == letter.lower():
result += 1

Choose a reason for hiding this comment

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

While this loop correctly implements the logic, the task guidelines recommend avoiding loops. Have you considered using Python's built-in string methods? For example, you could convert both the phrase and letter to the same case and then use the .count() method.


return result