Knowee
Questions
Features
Study Tools

Write a program that will take one string as input. The program will then remove vowels a, e, i, o, u (in lower or upper case) from the string. If there are two or more than two vowels that occur together then the program shall ignore all of those vowels.Sample input Cat Sample output CtSample input HeelSample output Heel

Question

Write a program that will take one string as input. The program will then remove vowels a, e, i, o, u (in lower or upper case) from the string. If there are two or more than two vowels that occur together then the program shall ignore all of those vowels.Sample input Cat Sample output CtSample input HeelSample output Heel

🧐 Not the exact question you are looking for?Go ask a question

Solution

Here is a Python program that accomplishes this task:

def remove_vowels(s):
    vowels = 'aeiouAEIOU'
    result = ''
    i = 0
    while i < len(s):
        if s[i] not in vowels:
            result += s[i]
            i += 1
        else:
            while i < len(s) and s[i] in vowels:
                i += 1
    return result

# Test the function
print(remove_vowels('Cat'))  # Output: Ct
print(remove_vowels('Heel'))  # Output: Heel

This program works by iterating over each character in the input string. If the character is not a vowel, it is added to the result string. If the character is a vowel, the program skips over all consecutive vowels before continuing.

Please note that in the example you provided, the output for 'Heel' is the same as the input. This is because the two vowels 'e' and 'e' occur together, so according to the problem statement, they are ignored (i.e., not removed).

This problem has been solved

Similar Questions

Define a function remove_vowel(string1). The function return string1 with all vowels removed. Vowels are any of a, e, i, o, u and A, E, I, O, U.Exampleremove_vowel('python') -> 'pythn'remove_vowel('I love ice cream') -> ' lv c crm'Hintyou can check if a character or an element (not) in a string or a list by using in, or not in.

Write a function that takes a string as input and returns a new string with all the vowels removed.

Q) Write a program to input a string and convert it into uppercase and print the pair of vowels and number of pair of vowels occurring in the string. Example: Input: "BEAUTIFUL BEAUTIES " Output : Pair of vowels: EA, AU, EA, AU, IE No. of pair of vowels: 5

Take character as input from the console using input() function. Write a program to check whether the given input is a vowel or a consonant or a letter are not. Print the result to the console as shown in the examples.Sample Input and Output 1:ch: Aletter and vowelSample Input and Output 2:ch: Pletter and consonantSample Input and Output 3:ch: @not letter

#Write a Python function count_vowels(text) that takes a string as input and returns the count of vowels (a, e, i, o, u) in the input string, ignoring case.

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.