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

'Solution' #2016

Closed
wants to merge 2 commits into from
Closed

'Solution' #2016

wants to merge 2 commits into from

Conversation

Danylo-Ok
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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


Hello! 😊 It looks like there's a critical issue with the logic of your count_occurrences function. The count variable is being reset inside the loop, which means it doesn't correctly tally the total occurrences of the specified letter in the phrase. To fix this, you should initialize count to 0 before the loop begins. Additionally, consider using Python's built-in str.count() method for a more efficient solution without a loop. Keep up the great work, and I'm sure you'll nail it with these adjustments! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

app/main.py Outdated
Comment on lines 2 to 3
for char in phrase:
count = 0

Choose a reason for hiding this comment

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

The count variable is initialized to 0 inside the loop. This causes the count to reset to 0 for each character in the phrase, resulting in the function always returning 0 or 1. To fix this, initialize count to 0 before the loop starts.

@Danylo-Ok Danylo-Ok closed this Nov 23, 2024
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

Successfully merging this pull request may close these issues.

2 participants