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

completed the task , py-count-occurences #678

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

Conversation

tkachuk2291
Copy link

No description provided.

app/main.py Outdated
@@ -14,4 +14,8 @@ def count_occurrences(phrase: str, letter: str) -> int:
:param letter: letter to find occurrences of it
:return: count occurrences of letter in phrase
"""
# write your code here
count = 0
for i in range(len(phrase)):

Choose a reason for hiding this comment

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

You can iterate through elements instead of indexes

Copy link

@ArsenPidhoretskyi ArsenPidhoretskyi left a comment

Choose a reason for hiding this comment

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

Changes requested

@tkachuk2291
Copy link
Author

Edit solutions

@tkachuk2291 tkachuk2291 closed this Jul 1, 2023
@tkachuk2291 tkachuk2291 reopened this Jul 1, 2023
app/main.py Outdated
Comment on lines 2 to 6
count = 0
for char in phrase:
if char.lower() == letter.lower():
count += 1
return count

Choose a reason for hiding this comment

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

You can write this inline instead of loop

app/main.py Outdated
# write your code here
"""""

return sum(1 for i in phrase if i.lower() == letter.lower())

Choose a reason for hiding this comment

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

what is i? use more accurate name

app/main.py Outdated
Comment on lines 18 to 19
return sum(1 for character in phrase
if character.lower() == letter.lower())
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to use sum use count

@tkachuk2291 tkachuk2291 requested a review from vsmutok October 18, 2023 10:44
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.

5 participants