Skip to content

Assignment1#2

Open
PapaVafa wants to merge 8 commits intomainfrom
assignment1
Open

Assignment1#2
PapaVafa wants to merge 8 commits intomainfrom
assignment1

Conversation

@PapaVafa
Copy link
Copy Markdown
Owner

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

I wrote the code

What did you learn from the changes you have made?

I learned the basic coding in puthon

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

I guess there are some other approaches

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

The merging the branches were challenging

How were these changes tested?

yes it was

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

Checklist

  • I can confirm that my changes are working as intended

" word_a=word_a.lower()\n",
" for letter in word_a:\n",
" if letter in word_b:\n",
" result==True \n",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This should be
result=True
as we are assigning the value to result, not evaluating it

" if letter in word_b:\n",
" result==True \n",
" else:\n",
" result==False \n",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This should be
result=False
as we are assigning the value to result, not evaluating it

"def anagram_checker(word_a, word_b):\n",
" result=True\n",
" word_a=word_a.lower()\n",
" for letter in word_a:\n",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It's a misuse of for loop here.
In this code, it's going to loop over every letter in word_a , and return True if a letter is in a word_b, and False if a letter is not in word_b. This is incorrect because:

  • If we anagram_checker('aaa', 'apple'), it's going to return True, because every letter in word_a exists in word_b. However, this is incorrect, as 'aaa' and 'apple' are not anagrams.
  • The result variable is assigned to True or False based on a single letter instead of basing on a word. The value is also changing in each iteraction.

We don't need a for loop to compare word_a and word_b. Simply do the following:
result = word_a.lower() == word_b.lower()

" if letter in word_b:\n",
" result=True \n",
" result=False \n",
" elif is_case_sensitive==False:\n",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We can also just do else

" elif is_case_sensitive==False:\n",
" word_a=word_a.lower()\n",
" word_b=word_b.lower()\n",
" for letter in word_a:\n",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same issue with for loop misuse. Please see previous comments.

Copy link
Copy Markdown

@kelichiu kelichiu left a comment

Choose a reason for hiding this comment

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

Incomplete

Code Execution

Code cells execute with errors.

Code Quality

  • Code is well-organized.
  • Great use of variable names.

Copy link
Copy Markdown

@kelichiu kelichiu left a comment

Choose a reason for hiding this comment

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

Pass

Code Execution

All code cells execute without errors.

Code Quality

  • Code is well-organized, concise.
  • Great use of variable names.

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