This is a Python Program to check if a string is a pangram or not.
The program takes a string and checks if it is a pangram or not.
1. Take a string from the user and store it in a variable.
2. Pass the string as an argument to a function.
3. In the function, form two sets- one of all lower case letters and one of the letters in the string.
4. Subtract these both sets and check if it is equal to an empty set.
5. Print the final result.
Here is source code of the Python Program to check if a string is a pangram or not. The program output is also shown below.
from string import ascii_lowercase as asc_lower def check(s): return set(asc_lower) - set(s.lower()) == set() strng=raw_input("Enter string:") if(check(strng)==True): print("The string is a pangram") else: print("The string isn't a pangram")
1. User must enter a string and store it in a variable.
2. The string is passed as an argument to a function.
3. In the function, two sets are formed- one for all lower case letters and one for the letters in the string.
4. The two sets are subtracted and if it is an empty set, the string is a pangram.
6. The final result is printed.
Case 1: Enter string:The quick brown fox jumps over the lazy dog The string is a pangram Case 2: Enter string:Hello world The string isn't a pangram
Sanfoundry Global Education & Learning Series – Python Programs.
To practice all Python programs, here is complete set of 150+ Python Problems and Solutions.