MENU
Question -

Write a program that reads a string and display the longest substring of the given string having just the consonants.



Answer -

string = raw_input (“Enter a string :”)
length = len (string)
max length = 0
max sub = ‘ ‘
sub = ‘ ‘
lensub = 0
for a in range (length) :
if string [a] in aeiou ‘or string [a] in’AEIOU’:
if lensub > maxlength :
maxsub = sub
maxlength – lensub
sub = ‘ ‘
lensub 0
else :
sub += string[a]
lensub = len(sub)
a + = 1
print “Maximum length consonent
substring is :”, maxsub,
print “with”, maxlength, “characters”

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
Any questions? Ask us!
×