codescracker


python

Python Program to Remove Vowels from String



« Previous Program Next Program »


Remove Vowels from String in Python

To remove all vowels present in a string in python, you have to ask from user to enter a string and start removing all vowels from it. After removing all vowels from that string, print the final string without any vowel as output as shown in the program given below.

Python Programming Code to Remove Vowels from String

Following python program ask from user to enter any string to remove all vowels from that string and then prints that string without any vowel:

# Python Program - Remove Vowels from String
		
while True:
	print("Enter 'x' for exit.")
	string = input("Enter any string: ")
	if string == 'x':
		break
	else:
		newstr = string
		print("\nRemoving vowels from the given string...")
		vowels = ('a', 'e', 'i', 'o', 'u')
		for x in string.lower():
			if x in vowels:
				newstr = newstr.replace(x,"")
		print("New string after successfully removing all vowels!")
		print(newstr,"\n")

Here is the sample run of the above python program to illustrates how to remove all vowels from a string:

python remove vowels from string

Same Program in Other Languages

You may also like to learn or practice the same program in other popular programming languages:


« Previous Program Next Program »




Tools
Calculator

Quick Links
Signup - Login - Give Online Test