Skip to content
Open
Changes from all commits
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
7 changes: 5 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
def count_occurrences(phrase: str, letter: str) -> int:
# write your code here
pass
count = 0
for lett in phrase.upper():
if lett == letter.upper():
count += 1
return count
Comment on lines +2 to +6

Choose a reason for hiding this comment

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

This loop-based approach works correctly, which is great! For a more Pythonic and concise solution, as recommended in the task guidelines, you could explore Python's built-in string methods. Is there a method that can count occurrences of a substring directly?