Skip to content

Commit cad5281

Browse files
committed
docs(pangram): improve approach's content and links
1 parent b4259d9 commit cad5281

File tree

1 file changed

+5
-6
lines changed
  • exercises/practice/pangram/.approaches/set-len

1 file changed

+5
-6
lines changed

exercises/practice/pangram/.approaches/set-len/content.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ def is_pangram(sentence):
66
```
77

88
- This approach first makes a [set][set] from the [`lower`][lower]cased characters of the `sentence`.
9-
- The characters in the `set`are then iterated in a [list comprehension][list-comprehension].
10-
- The characters are filtered by an `if` [`isalpha()`][isalpha] statement, so that only alphabetic characters make it into the list.
11-
- The function returns whether the [`len()`][len] of the [`list`][list] is `26`.
12-
If the number of unique letters in the `set` is equal to the `26` letters in the alphabet, then the function will return `True`.
9+
- The characters are filtered using a [set comprehension][set-comprehension] with an `if` [`isalpha()`][isalpha] statement, so that only alphabetic characters make it into the set.
10+
- The function returns whether the [`len()`][len] of the [`set`][set] is `26`.
11+
If the number of unique ASCII letters in the `set` is equal to the `26` letters in the ASCII alphabet, then the function will return `True`.
12+
- This approach is efficient because it uses a set to eliminate duplicates and directly checks the length, which is a constant time operation.
1313

1414
[lower]: https://docs.python.org/3/library/stdtypes.html?#str.lower
1515
[set]: https://docs.python.org/3/library/stdtypes.html?#set
16-
[list-comprehension]: https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions
16+
[set-comprehension]: https://realpython.com/python-set-comprehension/#introducing-set-comprehensions
1717
[isalpha]: https://docs.python.org/3/library/stdtypes.html?highlight=isalpha#str.isalpha
1818
[len]: https://docs.python.org/3/library/functions.html?#len
19-
[list]: https://docs.python.org/3/library/stdtypes.html?#list

0 commit comments

Comments
 (0)