Skip to content
Open
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
28 changes: 27 additions & 1 deletion 02_activities/assignments/assignment_1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"source": [
"# This is a function, which we will learn more about next week. For testing purposes, we will write our code in the function\n",
"def anagram_checker(word_a, word_b):\n",
" # Your code here\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 All @@ -86,6 +86,13 @@
"anagram_checker(\"night\", \"Thing\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -117,6 +124,25 @@
"anagram_checker(\"Silent\", \"Listen\", True) # False"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Function to check for anagrams\n",
"def anagram_checker(word_a, word_b, is_case_sensitive):\n",
" #if we are checking for case sensitivity enter if statement\n",
" if is_case_sensitive:\n",
" #return sorted list checking if they are equal\n",
" return sorted(word_a) == sorted(word_b)\n",
" #if not checking for case sensitivity then return sorted list of characters of the string converted to lowercase checking if they are equal \n",
" return (sorted(word_a.lower()) == sorted(word_b.lower()))\n",
"\n",
"# Run code:\n",
"print(anagram_checker(\"Silent\", \"Listen\", False))\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down