MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / is_pangram

Function is_pangram

strings/is_pangram.py:6–32  ·  view source on GitHub ↗

A Pangram String contains all the alphabets at least once. >>> is_pangram("The quick brown fox jumps over the lazy dog") True >>> is_pangram("Waltz, bad nymph, for quick jigs vex.") True >>> is_pangram("Jived fox nymph grabs quick waltz.") True >>> is_pangram("My nam

(
    input_str: str = "The quick brown fox jumps over the lazy dog",
)

Source from the content-addressed store, hash-verified

4
5
6def is_pangram(
7 input_str: str = "The quick brown fox jumps over the lazy dog",
8) -> bool:
9 """
10 A Pangram String contains all the alphabets at least once.
11 >>> is_pangram("The quick brown fox jumps over the lazy dog")
12 True
13 >>> is_pangram("Waltz, bad nymph, for quick jigs vex.")
14 True
15 >>> is_pangram("Jived fox nymph grabs quick waltz.")
16 True
17 >>> is_pangram("My name is Unknown")
18 False
19 >>> is_pangram("The quick brown fox jumps over the la_y dog")
20 False
21 >>> is_pangram()
22 True
23 """
24 # Declare frequency as a set to have unique occurrences of letters
25 frequency = set()
26
27 # Replace all the whitespace in our sentence
28 input_str = input_str.replace(" ", "")
29 for alpha in input_str:
30 if "a" <= alpha.lower() <= "z":
31 frequency.add(alpha.lower())
32 return len(frequency) == 26
33
34
35def is_pangram_faster(

Callers

nothing calls this directly

Calls 1

addMethod · 0.45

Tested by

no test coverage detected