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.
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 print("Enter 'x' for exit.") string = input("Enter any string to remove all vowels from it: ") if string == 'x': exit(); 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 removed all the vowels:"); print(newstr);
Here is the sample run of the above python program to illustrates how to remove all vowels from a string:
Above one is the initial output produced after running the program, now you have to supply or enter any string say codescracker that contains some vowels (oeae) to remove all the containing vowels from that given string and print the same string back on output screen but without any vowels, that will be cdscrckr:
Same program on python shell:
You may also like to learn or practice the same program in other popular programming languages: