Practice Problem 6-Consogram

Practice Problem 6-Consogram

Consogram


Consograms are words or sentences that has every consonant( letters other than a,e,i,o,u) of the English alphabet occurring at least once. Write an algorithm and a subsequent Python code to check whether a string is a consogram or not. Write a function to check if a given string is a consogram. For example,”"The quick brown fox jumps over the lazy dog"" is a consogram.

Input format

First line contains the string to be checked

Output Format

Print Consogram or Not consogram


Input:
The string

Processing:
def consogram(s):
    con_count = {}
    s = s.lower()
    s = ''.join(s.split())
    s = set(s) - set('aeiou')
    if len(s) == 21:
        print('Consogram')
    else:
        print('Not consogram')

Output:
display whether the given string is a consogram or not

Program:
def consogram(s):
    con_count = {}
    s = s.lower()
    s = ''.join(s.split())
    s = set(s) - set('aeiou')
    if len(s) == 21:
        print('Consogram')
    else:
        print('Not consogram')

s = input()
consogram(s)

Algorithm:
Step1. define the function consogram with one parameter s
Step1.1 assign con_count as an empty dictionary
Step1.2 convert all the letters of s into lower case and remove all the whitespace characters
Step1.3 check if the number of consonants in s is 21 if yes then display the string is a consogram else display not consogram
Step2. get the string and check whether it is a consogram or not using the consogram function
Step3. End

Comments

Popular posts from this blog

MATLAB WEEK-2

PRACTICE PROBLEM 8

BONUS PRACTICE PROBLEMS