Python Remove Vowels in String Program – This Python program will take an input string from user. It will remove any vowels in this string and will display the output string after removing vowels in that input string.
We will use:
- input() function to display message and get the input string from the user.
- We will crate a list containing all vowels in small case and upper case: vowel_list = [‘a’, ‘e’, ‘i’, ‘o’, ‘u’, ‘A’, ‘E’, ‘I’, ‘O’, ‘U’]
- Define a new variable output_string that will store the result of this Python program that is, the string without vowels.
- Find length of the input_string.
- Use a for loop from 0 to n-1 where n represents the size of length of the string.
- In this coding, we will check if any vowel is present in the input string it will not be moved to output string whereas all other characters will be shifted.
- Using print() function to output the output string.
Python Remove Vowels in String Program
# ~~~* EasyCodeBook.com *~~~ # Program to remove vowels from a string input_string = input("Enter String To Cont Vowels:") vowel_list = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'] output_string = "" str_length = len(input_string) for i in range(str_length): if input_string[i] not in vowel_list: output_string = output_string + input_string[i] print("---------------------------------------\n"+ "Output String Without Vowels is: ") print(output_string)
Output
Enter String To Remove Vowels:abcde --------------------------------------- Output String Without Vowels is: bcd
You will also like: