Skip to content

UofT-DSI | Python - Assignment #1: Anagram Checker#4

Merged
hitechparadigm merged 10 commits intomainfrom
assignment-1
May 16, 2024
Merged

UofT-DSI | Python - Assignment #1: Anagram Checker#4
hitechparadigm merged 10 commits intomainfrom
assignment-1

Conversation

@hitechparadigm
Copy link
Copy Markdown
Owner

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

I have created two functions to check whether strings are anagrams.

What did you learn from the changes you have made?

I learned how to write functions, convert strings to lists, and compare them.

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

There is a very concise way to write the code to address the initial task (comparing just two single words).
However, I expanded the task a bit, and my Anagram Checker checks whether words and phrases (with punctuation) are anagrams.

The initial task (compare two words) can be addressed with this simple code:

# Part 1: 
def anagram_checker(word_a, word_b):
     return sorted(word_a.lower()) == sorted(word_b.lower())

# Part 2: 
def anagram_checker(word_a, word_b, is_case_sensitive):
  if  is_case_sensitive:
    return sorted(word_a) == sorted(word_b) 
  else:
    return sorted(word_a.lower()) == sorted(word_b.lower())

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

Not really.

How were these changes tested?

I used print() to check the outcomes and check the data type.
I used more anagrams to check how the functions work.

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

None.

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.

Great job! Your code is well-executed and commented.

@hitechparadigm hitechparadigm merged commit 46d9038 into main May 16, 2024
@hitechparadigm hitechparadigm deleted the assignment-1 branch May 16, 2024 02:40
@hitechparadigm hitechparadigm restored the assignment-1 branch May 16, 2024 02:40
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