Skip to content

Adding Assignmnet 1 with the answers#1

Open
elviravazquez wants to merge 2 commits intomainfrom
assignment-1
Open

Adding Assignmnet 1 with the answers#1
elviravazquez wants to merge 2 commits intomainfrom
assignment-1

Conversation

@elviravazquez
Copy link
Copy Markdown
Owner

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

  • 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.

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.

@elviravazquez
Copy link
Copy Markdown
Owner Author

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.

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!

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