Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Excellent work on this! Your solution correctly implements the count_occurrences function and passes all requirements, so I am approving it. You did a great job handling the case-insensitivity requirement by converting both inputs to lowercase.
For future reference, you can make your code a bit more concise. Instead of converting the string to a list, you can call the .count() method directly on the string itself. This would allow you to simplify your function into a single line: return phrase.lower().count(letter.lower()).
Also, a small tip on coding conventions: using English for variable names is standard practice and makes code easier for a wider audience to read. These are just suggestions for improvement—your code works perfectly. Keep up the great work!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| phrase_en_liste = list(phrase.lower()) | ||
| nombre_occurence = phrase_en_liste.count(letter.lower()) |
There was a problem hiding this comment.
While this solution works perfectly, the conversion of the phrase to a list is an unnecessary intermediate step. Python's string objects have their own count() method, which you can use directly on the lowercased string. You could combine lines 2, 3, and 4 into a single return statement for a more concise solution.
There was a problem hiding this comment.
Fixed in 5a3a660. Added ge=0 on offset and ge=1, le=5000 on limit via Field() constraints.
No description provided.