Skip to content

Commit d283965

Browse files
authored
docs: add check_pangram with doctests
Implement a function to check if a string is a pangram.
1 parent 2c15b8c commit d283965

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

strings/check_pangram.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
def check_pangram(input_str: str) -> bool:
2+
"""
3+
Check if a string is a pangram (contains every letter of the alphabet).
4+
>>> check_pangram("The quick brown fox jumps over the lazy dog")
5+
True
6+
>>> check_pangram("Hello World")
7+
False
8+
>>> check_pangram("")
9+
False
10+
"""
11+
return len(set(c for c in input_str.lower() if c.isalpha())) == 26
12+
13+
14+
if __name__ == "__main__":
15+
import doctest
16+
doctest.testmod()

0 commit comments

Comments
 (0)