Conversation
juliagallucci
left a comment
There was a problem hiding this comment.
You are on the right track. Your function checks whether letters from word_a appear in word_b, but this does not fully verify that the words are anagrams because it does not account for letter frequency or extra letters in word_b. A better approach would be to compare the sorted characters of both words (after adjusting case if needed) so that the function ensures both words contain the same letters in the same quantities. Please revise.
I've edited the function so that every time it checks a letter, it removes the letter. I also made the second function a bit shorter. |
What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)
I was adding the code for the function to check for anagrams.
What did you learn from the changes you have made?
I learned to use the .lower() methods for strings.
Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?
In the section function that accoundt for case sensitivity, instead of having and if statement that has 2 similar for loops depending on the case sensitivity, the if statement would create a new version of word_a and word_b using the lower method. That would make the code shorter.
Were there any challenges? If so, what issue(s) did you face? How did you overcome it?
I didn't face any challenges
How were these changes tested?
I ran the code.
A reference to a related issue in your repository (if applicable)
Checklist