Skip to content

python assignment 1 completed#1

Open
YanfeiLu wants to merge 4 commits intomainfrom
assignment-1
Open

python assignment 1 completed#1
YanfeiLu wants to merge 4 commits intomainfrom
assignment-1

Conversation

@YanfeiLu
Copy link
Copy Markdown
Owner

@YanfeiLu YanfeiLu commented Oct 17, 2025

What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)

Completed the assignment by completing the code.

What did you learn from the changes you have made?

How to use python to check if two words are anagrams of each other, as well as whether if they are case sensitive.

Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?

I used a lot of embedding to check one condition at a time. However, I think there might be other more concise approaches that checks if more than one conditions are satisfied at the same time.

Were there any challenges? If so, what issue(s) did you face? How did you overcome it?

Trying to figure out the logic, but it was really fun!

How were these changes tested?

I tested the code at intermediate steps.

A reference to a related issue in your repository (if applicable)

Checklist

  • I can confirm that my changes are working as intended

Copy link
Copy Markdown

@juliagallucci juliagallucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job outlining your logic step by step. Your code correctly lowers case and compares lengths, but placing return inside the loop causes it to exit after the first letter, so moving the return statement outside or using sorted() will fix this and make the anagram check accurate. Please revise.

Copy link
Copy Markdown

@juliagallucci juliagallucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good attempt, however, there’s a logical issue: it checks only whether all letters in word_b appear in word_a, not whether they appear the same number of times. Example, anagram_checker("aab", "abb") would incorrectly return True. Please revise.

Copy link
Copy Markdown

@juliagallucci juliagallucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good attempt. For part b, your current code always converts both words to lowercase before performing either the case-sensitive or case-insensitive comparison. That means it removes case information too early, so even when is_case_sensitive=True. Please revise

Copy link
Copy Markdown

@juliagallucci juliagallucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! One note for improvement, you don’t need to explicitly return True or False since the comparison itself already evaluates to a Boolean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants