-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Develop #1805
base: master
Are you sure you want to change the base?
Develop #1805
Conversation
app/main.py
Outdated
counter = 0 | ||
for i in range(len(phrase)): | ||
if phrase[i].lower() in letter.lower(): | ||
counter += 1 | ||
return counter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to write it in one line
use count
app/main.py
Outdated
return sum([1 for i in range(len(phrase)) | ||
if phrase[i].lower() == letter.lower()]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use method count of string.
https://www.w3schools.com/python/ref_string_count.asp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don`t understand
what i have do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should improve your code with using method count
of string. Something like this
return sum([1 for i in range(len(phrase)) | |
if phrase[i].lower() == letter.lower()]) | |
return phrase.lower().count(letter.lower()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amazing! thank you
app/main.py
Outdated
return sum([1 for i in range(len(phrase)) | ||
if phrase[i].lower() == letter.lower()]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should improve your code with using method count
of string. Something like this
return sum([1 for i in range(len(phrase)) | |
if phrase[i].lower() == letter.lower()]) | |
return phrase.lower().count(letter.lower()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.