|
56 | 56 | }, |
57 | 57 | { |
58 | 58 | "cell_type": "code", |
59 | | - "execution_count": 2, |
| 59 | + "execution_count": null, |
60 | 60 | "metadata": {}, |
61 | 61 | "outputs": [ |
62 | 62 | { |
|
73 | 73 | "source": [ |
74 | 74 | "# This is a function, which we will learn more about next week. For testing purposes, we will write our code in the function\n", |
75 | 75 | "def anagram_checker(word_a, word_b):\n", |
76 | | - " return set(word_a.lower()) == set(word_b.lower())\n", |
| 76 | + " # inputs: word_a and word_b are both strings\n", |
| 77 | + " # Compares the character set of word_a with that of word_b, using .lower() to make the comparison case-insensitive \n", |
| 78 | + " # output: boolean. returns True if the strings are anagrams (case-insensitive), False otherwise.\n", |
| 79 | + " return set(word_a.lower()) == set(word_b.lower()) \n", |
77 | 80 | "\n", |
78 | 81 | "# Run your code to check using the words below:\n", |
79 | 82 | "anagram_checker(\"Silent\", \"listen\")" |
|
146 | 149 | ], |
147 | 150 | "source": [ |
148 | 151 | "def anagram_checker(word_a, word_b, is_case_sensitive):\n", |
| 152 | + " # inputs: word_a and word_b are both strings, is_case_sensitive is boolean\n", |
| 153 | + " # Check that the character set in word_a is the same as word_b, \n", |
| 154 | + " # using .lower() method to make the comparison case-insensitive if is_case_sensitive is False,\n", |
| 155 | + " # otherwise compare the sets as-is.\n", |
| 156 | + " # output: boolean. returns True if the strings are anagrams, False otherwise.\n", |
| 157 | + "\n", |
149 | 158 | " return set(word_a.lower() if not is_case_sensitive else word_a) == set(word_b.lower() if not is_case_sensitive else word_b.lower())\n", |
150 | 159 | "\n", |
151 | 160 | "# Run your code to check using the words below:\n", |
|
0 commit comments