Questions

How do you Extract a Vowel from a String in Python?

In the program given below, we have discussed how to remove the vowels present in a string and return the string without any vowel present in it.  

For example:

Let us consider the string s=”Hi, I want to go to Beverly Hills for a vacation”

The compiler will remove all the vowels from the string ‘s’ and return the string.

Output:

H, wnt t g t Bvrly Hlls fr vctn

Source Code:

                    

string = input("Enter any string: ")

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);

Related Questions

Share with friends

Customize your course in 30 seconds

Which class are you in?
5th
6th
7th
8th
9th
10th
11th
12th
Get ready for all-new Live Classes!
Now learn Live with India's best teachers. Join courses with the best schedule and enjoy fun and interactive classes.
tutor
tutor
Ashhar Firdausi
IIT Roorkee
Biology
tutor
tutor
Dr. Nazma Shaik
VTU
Chemistry
tutor
tutor
Gaurav Tiwari
APJAKTU
Physics
Get Started

Leave a Reply

Your email address will not be published. Required fields are marked *

Download the App

Watch lectures, practise questions and take tests on the go.

Customize your course in 30 seconds

No thanks.