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 #1914

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Solution #1914

wants to merge 2 commits into from

Conversation

ostroverkhovaa
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.


Thank you for your effort on implementing the count_occurrences function! 😊 You've done a great job in making the function case insensitive and using Python's built-in string methods effectively. However, there's a small but critical issue that needs to be addressed: the function currently returns a float instead of an integer. This is because the return value is being inadvertently converted to a float. To fix this, simply return the result of phrase.lower().count(letter.lower()) directly, as it already provides the count as an integer. Once this is corrected, your solution will perfectly meet the task requirements. Keep up the great work! 🚀

✨ 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
@@ -1,3 +1,2 @@
def count_occurrences(phrase: str, letter: str) -> int:
# write your code here
pass
return phrase.lower().count(letter.lower())

Choose a reason for hiding this comment

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

The function count_occurrences is expected to return an integer, representing the count of occurrences of letter in phrase. However, the current implementation returns a float because the count method is used correctly, but there is no need for division. Simply return the result of phrase.lower().count(letter.lower()) to get an integer.

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.

Great job on implementing the count_occurrences function! 🎉 Your solution effectively counts the occurrences of a letter in a phrase, ignoring case, and aligns well with the task requirements. However, there's a small issue in the return statement where the result of the count method is unnecessarily cast to an integer. Since count already returns an integer, you can simply return phrase.lower().count(letter.lower()) without the int() conversion.

This decision to approve is made to help you move forward with your learning journey. Please review the comments to improve your code. Addressing such issues will enhance your coding skills and help avoid similar problems in the future. Keep up the great work and continue learning from your experiences! 😊

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

@@ -1,3 +1,2 @@
def count_occurrences(phrase: str, letter: str) -> int:
# write your code here
pass
return int(phrase.lower().count(letter.lower()))

Choose a reason for hiding this comment

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

The return statement should not cast the result of count to an integer. The count method already returns an integer, so the int() conversion is unnecessary and misleading. Simply return phrase.lower().count(letter.lower()).

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