Python program to remove the vowels from a string
Remove the vowels from a string
The string is built with 2 different types of alphabets grouped as vowels and consonants. In this python program, we will be searching for each alphabet that belongs to the group of vowels and will delete it and print the strings with remaining consonants. As we know String is un-mutable in python so we will initialize a new string and concatenate alphabets that don’t belong to the group of vowels and print it.
- Step 1:- Start.
- Step 2:- Take user input as string.
- Step 3:- Initialize a new empty string as string1.
- Step 4:- Use for loop to iterate through the string.
- Step 5:- Check for the vowels.
- Step 6:- If alphabet is not from group of vowels concatenate it to string1.
- Step 7:- Print String1.
- Step 8:- End.
Python Program to remove vowels from a string
#take user input String = input('Enter string :') #initialize new empty string String1 = str() String = String.lower() for i in String: #check condition if alphabet belong to group of vowels if i == 'a' or i == 'e' or i == 'i' or i == 'o' or i == 'u': pass else: String1 = String1 + i #check for if the string1 is not null if len(String1) == 0: print('No vowel found in ' + String) else: print(String + ' after removing vowels ' + String1)
Enter string :PopatLal
popatlal after removing vowels pptll