You are given a string which may contain uppercase letters, lower case letters, white spaces, commas (,), and periods(.). Remove following vowels from the given string. ‘a’,’e’,’I’,’o’,’u’,’A’,’E’,’I’,’O’,’U’. It is guaranteed that: There are no two consecutive white spaces in the given strings There are no white spaces at the start and at the end of the given string You will not get an empty string as a result. Input: The first line of i/p contains an integer ‘n’, the length of the given string. Second line of input contain a string. Output: Print the given string without vowels. If the result string contains whitespaces at the start or at the end you must remove them. Constraints: 1<=n<=100 Case 1: Input: 7 E Hello Output: Hll

Respuesta :

Answer:

# The user is prompt to enter the length of the string

length = int(input("Enter length of string: "))

# While the input length is greater than 100

# the prompt keep asking user to enter between 1 and 100

while (length < 1 and length > 100):

 print("The length must be between 1 and 100")

 length = int(input("Enter length of string: "))

# user is asked to enter the string

word = str(input("Enter the string: "))  

# the new word is initialized as empty string

new_word = ""

# the vowel is placed in a list

vowel = ['a', 'e', 'I', 'o', 'u', 'A', 'E', 'I', 'O', 'U']

# for loop through the inputted word

# if the letter is in vowel, it skip

for letter in word:

 if letter in vowel:

   continue

 else:

   new_word += letter  

# the new word is displayed to user

print(new_word)    

Explanation:

The code is written in Python3 and it is well commented. Image of program output when it is executed is attached.

The program asked for the length of string and it make sure it is between 1 and 100.

It then asked for the string which is assigned to word. It then loop through the word, if it found a vowel, it skip else it concatenate with the new word.

Ver imagen ibnahmadbello