Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions 02_activities/assignments/assignment_1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@
"source": [
"# For testing purposes, we will write our code in the function\n",
"def anagram_checker(word_a, word_b):\n",
" # Your code here\n",
" # .lower() looks at every letter and converts uppercase to lowercase so that comparisons ignore case \n",
" # sorted compares sorted letters\n",
" return(sorted(word_a.lower()) == sorted(word_b.lower()))\n",
"\n",
"# Run your code to check using the words below:\n",
"anagram_checker(\"Silent\", \"listen\")"
Expand Down Expand Up @@ -102,7 +104,13 @@
"outputs": [],
"source": [
"def anagram_checker(word_a, word_b, is_case_sensitive):\n",
" # Modify your existing code here\n",
" # If not case sensitive, convert both words to lowercase\n",
" if not is_case_sensitive:\n",
" word_a = word_a.lower()\n",
" word_b = word_b.lower()\n",
" return sorted(word_a) == sorted(word_b)\n",
" else: \n",
" return sorted(word_a) == sorted(word_b)\n",
"\n",
"# Run your code to check using the words below:\n",
"anagram_checker(\"Silent\", \"listen\", False) # True"
Expand Down