🛠️ToolsShed

Pangram Checker

Check if text contains all 26 letters of the English alphabet.

PangramChecker.examples:

Perguntas Frequentes

Implementação de Código

def is_pangram(text: str) -> bool:
    """Check if text contains all 26 letters of the English alphabet."""
    letters = set(text.lower())
    return set('abcdefghijklmnopqrstuvwxyz').issubset(letters)

def missing_letters(text: str) -> list[str]:
    """Return letters missing from the text."""
    present = set(text.lower())
    return [c for c in 'abcdefghijklmnopqrstuvwxyz' if c not in present]

def pangram_stats(text: str) -> dict:
    present = set(c for c in text.lower() if c.isalpha())
    missing = [c for c in 'abcdefghijklmnopqrstuvwxyz' if c not in present]
    return {
        'is_pangram': len(missing) == 0,
        'present_count': len(present),
        'missing': missing,
        'unique_letters': sorted(present),
    }

examples = [
    "The quick brown fox jumps over the lazy dog",
    "Hello World",
    "Pack my box with five dozen liquor jugs",
]
for text in examples:
    stats = pangram_stats(text)
    print(f"'{text[:30]}...' -> pangram={stats['is_pangram']}, missing={stats['missing']}")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.