Open
Conversation
…o assignment-1 accidently got ahead of my assignment branch/fork on github?
…pecify if we want to consider case when evaluating if two words are anagrams or not
juliagallucci
approved these changes
Mar 16, 2026
juliagallucci
left a comment
There was a problem hiding this comment.
Good. Your code is modular and readable, but it is overly verbose for a simple anagram check. Returning printed messages instead of a Boolean and using unnecessary loops makes it less efficient and harder to use! I’d suggest simplifying the function by removing unnecessary loops and directly using sorted(word_a) and sorted(word_b) for comparison, and returning a Boolean instead of printing messages!
…se in favour of more direct functions and boolean responses
…se in favour of more direct functions and boolean responses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)
Completion of Python assignment 1.
What did you learn from the changes you have made?
I originally made for loops to iterate through the word and append each character to a list. I did not think that was the most efficient so I tried to use .extend() but then realized that is only for lists that already exist. So I would have had to put the word into a list and then extract it with extend, and then delete the original word. This seemed more messy than working with loops so I decided to stick with loops. For part 2, I decided to try and make my code more readable by breaking down the steps into functions. So I used those helper functions in the main anagram checker function. I learned that I have to return the actual outputs in some cases since when I tried to sort the lists of characters, it was not permanent and it was then comparing None to None and always showing an anagram. In the original version it did not do that so it was good to learn.
Since I know that loops can be computationally expensive, I tried to use some quicker, less intensive checks to determine if there were issues before letting it get tot the loop. I checked that the inputs were actually strings (and not Int or float). I also checked the length of the words since they should be the same if they are anagrams. If not, it would exit early and give a response.
##Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?
I tried to use .extend() function but realized it was for lists. For the second part I used more sub functions. The benefit of sub functions is that I could use them again in other code (had I had to write more larger functions).
Were there any challenges? If so, what issue(s) did you face? How did you overcome it?
Described above. I mostly used the examples in the repo and google to help figure out why my code was not working when I was using sub functions.
How were these changes tested?
I added some extra tests.
A reference to a related issue in your repository (if applicable)
Checklist