File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ """Pangram Checker.
2+
3+ This module contains functions to check if a string is a pangram.
4+ A pangram is a sentence that contains every letter of the alphabet at least once.
5+ """
6+
7+ import string
8+
9+
10+ def is_pangram (text : str ) -> bool :
11+ """
12+ Check if a given string is a pangram.
13+
14+ A pangram is a string that contains every letter of the alphabet
15+ at least once, ignoring case and non-alphabetic characters.
16+
17+ Args:
18+ text: The string to check
19+
20+ Returns:
21+ True if the string is a pangram, False otherwise
22+
23+ Examples:
24+ >>> is_pangram("The quick brown fox jumps over the lazy dog")
25+ True
26+ >>> is_pangram("Hello World")
27+ False
28+ >>> is_pangram("Pack my box with five dozen liquor jugs")
29+ True
30+ >>> is_pangram("abcdefghijklmnopqrstuvwxyz")
31+ True
32+ >>> is_pangram("")
33+ False
34+ >>> is_pangram("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
35+ True
36+ """
37+ # Convert text to lowercase and get all unique letters
38+ letters = set (char .lower () for char in text if char .isalpha ())
39+ # Check if all 26 letters of the alphabet are present
40+ return len (letters ) == 26
41+
42+
43+ if __name__ == "__main__" :
44+ import doctest
45+
46+ doctest .testmod ()
You can’t perform that action at this time.
0 commit comments