Write a Python program to strip a set of characters from a string


The program is written in Python and removes all occurrences of the vowels (lowercase and uppercase) from a given string. It first defines a string str and assigns it the value "Tutor Joes Computer Education". It also defines a string ch and assigns it the value "aeiouAEIOU", which represents all the vowels in both lowercase and uppercase.

Then, it uses the print() function to display the original string. The next step is to use a list comprehension and the join() method to create a new string that contains all the characters from the original string str except for the vowels.

The list comprehension iterates over the characters in the string str and uses an if clause to only include characters in the output list if they are not in the string ch of vowels. The join() method is used to concatenate all the characters in the output list into a single string, separated by a space character. Finally, the new string without vowels is displayed using the print() function.

Source Code

str = "Tutor Joes Computer Education"
ch = "aeiouAEIOU"
print("Original String : ",str)
print("After stripping aeiou AEIOU :"," ".join(c for c in str if c not in ch))

Output

Original String :  Tutor Joes Computer Education
After stripping aeiou AEIOU : T t r   J s   C m p t r   d c t n


Example Programs