Computer Science, asked by Anamikaas04, 6 months ago

Write a program that reads a string and displays the longest substring of the given string.[both vowels and consonants]

[[∆ topic: Strings in Python∆]]
❌DO NOT SPAM❌​

Answers

Answered by Anonymous
1

Explanation:

1. string = input("Enter a string:")

2. length = len(string) =

3. maxlength = 0

4. maxsub ="

5. sub ="

6. lensub = 0

voel Tall 88%

#empty string

#empty string

7. for a in range(length):

8.

if string[a] in 'aeiou' or string[a] in 'AEIOU' :

maxsub = sub

maxlength = lensub

sub = "

lensub = 0

else:

sub += string[a]

lensub = len(sub)

a += 1

9. maxsub = sub

10.maxlength = lensub

11.sub = "

12.lensub = 0

13.else:

14.sub += string[a]

15.lensub = len(sub)

16.a += 1

17. print ("Maximum length consonant substring is :", maxsub, end = '")

18. print ("with", maxlength, "characters")

i found this on web

see if this can help u

Answered by pawansaklani4747
0

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”, max

Similar questions