Conversation
xindizhang
approved these changes
Dec 3, 2025
There was a problem hiding this comment.
Excellent work! Your code is clean, well-documented, and well-written and your PR description is clear. Your assignment 1 is complete – no changes needed.
Please see my minor suggestion for future improvement:
- In places like:
if sorted(word_a.lower()) == sorted(word_b.lower()): #added lower because I inadvertently made a case sensitive anagram checker if sorted (word_a) == sorted(word_b)
return True
else:
return False
You can simplify this by directly returning the boolean expression:
return sorted(word_a.lower()) == sorted(word_b.lower())
This makes the code cleaner
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.
UofT-DSI | Python - Assignment 1
What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)
I expanded the existing anagram_checker function to include a new boolean parameter called is_case_sensitive. Based on this parameter, the function should either compare the words exactly as written (case sensitive) or compare lowercase versions of the words (not case sensitive).
What did you learn from the changes you have made?
I learned how Python handles boolean values differently from strings and how important indentation is for maintaining proper control flow. I also learned the difference between sorted() vs .sort(), how return statements stop code execution, and how to structure a function so all conditions are reachable
Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?
Yes, I considered creating separate helper functions. One for case-sensitive comparison and another for non-case-sensitive comparison and calling them based on the boolean value. I also thought about converting the words first and storing them in temporary variables before comparing.
Were there any challenges? If so, what issue(s) did you face? How did you overcome it?
Yes, I ran into indentation errors that caused the else blocks to be misaligned.
I also initially compared boolean values as strings ('True' instead of True).
I corrected these issues by aligning the if/else blocks properly, removing unreachable code, and ensuring I used boolean logic correctly (if is_case_sensitive:).
How were these changes tested?
I tested the function using multiple word pairs provided and all test returned the expected results.
A reference to a related issue in your repository (if applicable)
N/A
Checklist