Skip to content
Merged
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
16 changes: 14 additions & 2 deletions 02_activities/assignments/assignment_1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@
"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",
" \"\"\" Determine whther two strings are anagrams of each other (case-insensitive)\n",
" Retruns True if they are otherwise False\"\"\"\n",
" \n",
" # Case-insensitive: fold both strings to lowercase\n",
" word1 = word_a.casefold()\n",
" word2= word_b.casefold()\n",
" # Anagrams will have identical sorted character lists\n",
" return sorted(word1) == sorted(word2)\n",
"\n",
"# Run your code to check using the words below:\n",
"anagram_checker(\"Silent\", \"listen\")"
Expand Down Expand Up @@ -102,7 +109,12 @@
"outputs": [],
"source": [
"def anagram_checker(word_a, word_b, is_case_sensitive):\n",
" # Modify your existing code here\n",
" \"\"\" Determine whther two strings are anagrams of each other (case-sensitive)\"\"\"\n",
" if not is_case_sensitive:\n",
" # Case-insensitive comparison\n",
" word_a = word_a.casefold()\n",
" word_b = word_b.casefold()\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