Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)

def pangram(s):

    check=""

    small=s.lower()

    combine=small.replace(" ","")

    for i in combine:

        if i in check:

            return False

        else:

            check+=i

    return True

print(pangram("The quick brown fox jumps over the lazy dog"))

#Note : Pangrams are words or sentences containing every letter of the alphabet at least once.

Let's say, e.g., "The quick brown fox jumps over the lazy dog"

I can't find out what's wrong with my code...

1 Answer

0 votes
by (107k points)

First, you need to import the string package from the python environment: 

import string

def ispangram(sentence, alphabet=string.ascii_lowercase): 

    return set(alphabet) <= set(sentence.lower()) 

print(ispangram(input('Sentence: ')))

set(alphabet) #creates a set of all characters of a given alphabet.

set(sentence.lower())# creates a set of all characters of the input sentence in lower case.

The comparison set(alphabet) <= set(sentence.lower() checks if the characters of the sentence are at least the characters of the alphabet.

Related questions

0 votes
1 answer
asked Oct 10, 2019 in Python by Sammy (47.6k points)
0 votes
0 answers
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...