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!
×