|
169 | 169 | "duplicates = []\n",
|
170 | 170 | "for char in string:\n",
|
171 | 171 | " ## checking whether the character have a duplicate or not\n",
|
172 |
| - " ## str.count(char) returns the frequency of a char in the str\n", |
| 172 | + " ## string.count(char) returns the frequency of a char in the string\n", |
173 | 173 | " if string.count(char) > 1:\n",
|
174 | 174 | " if char not in duplicates:\n",
|
175 | 175 | " duplicates.append(char)\n",
|
|
193 | 193 | ],
|
194 | 194 | "source": [
|
195 | 195 | "import string\n",
|
196 |
| - "# special characters\n", |
| 196 | + "# special characters which contains all punctionmarks in it\n", |
197 | 197 | "special_chars = string.punctuation\n",
|
198 | 198 | "# initializing a string\n",
|
199 | 199 | "str1 = \"@k@$#Borg@lli!\"\n",
|
200 | 200 | "str2 = \"AkashBorgalli\"\n",
|
201 |
| - "# checking the special chars in the string_1\n", |
| 201 | + "# checking the special chars in the str1\n", |
202 | 202 | "boolvalue = list(map(lambda char: char in special_chars, str1))\n",
|
203 | 203 | "print(\"It contains special characters\") if any(boolvalue) else print(\"Doesnot contains any special characters\")\n",
|
204 |
| - "# checking the special chars in the string_2\n", |
| 204 | + "# checking the special chars in the str2\n", |
205 | 205 | "boolvalue = list(map(lambda char: char in special_chars, str2))\n",
|
206 | 206 | "print(\"It contains special characters\") if any(boolvalue) else print(\"Doesnot contains any special characters\")"
|
207 | 207 | ]
|
|
0 commit comments