Conversation
| " word_a=word_a.lower()\n", | ||
| " for letter in word_a:\n", | ||
| " if letter in word_b:\n", | ||
| " result==True \n", |
There was a problem hiding this comment.
This should be
result=True
as we are assigning the value to result, not evaluating it
| " if letter in word_b:\n", | ||
| " result==True \n", | ||
| " else:\n", | ||
| " result==False \n", |
There was a problem hiding this comment.
This should be
result=False
as we are assigning the value to result, not evaluating it
| "def anagram_checker(word_a, word_b):\n", | ||
| " result=True\n", | ||
| " word_a=word_a.lower()\n", | ||
| " for letter in word_a:\n", |
There was a problem hiding this comment.
It's a misuse of for loop here.
In this code, it's going to loop over every letter in word_a , and return True if a letter is in a word_b, and False if a letter is not in word_b. This is incorrect because:
- If we anagram_checker('aaa', 'apple'), it's going to return True, because every letter in word_a exists in word_b. However, this is incorrect, as 'aaa' and 'apple' are not anagrams.
- The
resultvariable is assigned to True or False based on a single letter instead of basing on a word. The value is also changing in each iteraction.
We don't need a for loop to compare word_a and word_b. Simply do the following:
result = word_a.lower() == word_b.lower()
| " if letter in word_b:\n", | ||
| " result=True \n", | ||
| " result=False \n", | ||
| " elif is_case_sensitive==False:\n", |
| " elif is_case_sensitive==False:\n", | ||
| " word_a=word_a.lower()\n", | ||
| " word_b=word_b.lower()\n", | ||
| " for letter in word_a:\n", |
There was a problem hiding this comment.
Same issue with for loop misuse. Please see previous comments.
kelichiu
left a comment
There was a problem hiding this comment.
Incomplete
Code Execution
Code cells execute with errors.
Code Quality
- Code is well-organized.
- Great use of variable names.
Execute the functions to make sure there is no error
Modify this code based on the recommendations.
Modify the code and address all the comments
kelichiu
left a comment
There was a problem hiding this comment.
Pass
Code Execution
All code cells execute without errors.
Code Quality
- Code is well-organized, concise.
- Great use of variable names.
What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)
I wrote the code
What did you learn from the changes you have made?
I learned the basic coding in puthon
Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?
I guess there are some other approaches
Were there any challenges? If so, what issue(s) did you face? How did you overcome it?
The merging the branches were challenging
How were these changes tested?
yes it was
A reference to a related issue in your repository (if applicable)
Checklist