According to the parameters given in the questions above, the alphabetically lowest and highest substrings that start with a vowel and end with a Consonant is given below.
<h3>What is the determined substrings described above?</h3>
The determined substring is given by the following:
def findSubstrings(s):
sub_strings_list=[] #the required substrings list
vowels=['a','e','i','o','u'] #vowels list
for i in range(0,len(s)):
for j in range(i+1,len(s)+1):
sub_string=s[i:j] #slicing the original string into substring
#checking whether the substring starts with a vowel and ends with a consonant
if(sub_string[0] in vowels and sub_string[-1] not in vowels):
if(sub_string not in sub_strings_list): #checking if the substring is already in the list
sub_strings_list.append(sub_string) #if all conditions are satisfied adding the substring to the list
sub_strings_list.sort() #sorting the list alphabetically
print(sub_strings_list[0]) #printing the first substring in the list
print(sub_strings_list[-1]) #printing the last substring in the list
s=input()
findSubstrings(s)
Learn more about substrings:
brainly.com/question/21306076
#SPJ4
Full Question:
Consider a string, s — An alphabetically-ordered sequence Of Of s would be {"a", "ab•, "abc • , "bcu, If the sequence is reduced to only those substrings that start with a vowel and end with a consonant, the result is Cab", •abc"}. The alphabetically first element in this reduced list is •ab", and the alphabetically last element is "abc'. As a reminder:
Vowels: a, e, i, o, and u.
Consonants: b, c, d, f, g, h, i, k, l, m, n, p, q, r, s, t, v, w, x, y, and z.
For a given string, determine the alphabetically lowest and highest substrings that start with a vowel and end with a Consonant.