How to Delete Vowels from a String in Python – GATE, Interview & Placement Practice
264 views
Jun 1, 2025
Get the full source code of application here:
View Video Transcript
0:00
uh hello guys welcome to this video so
0:02
in this video I will show you a very py
0:04
very common program which is asked
0:05
inside Python interviews placements and
0:08
competitive exams such as GATE so how to
0:11
remove vowels from a sentence vowels are
0:16
as you know it's a e i o
0:20
u
0:22
so vowels are special kind of uh
0:26
variables which exist in the which
0:30
which these are vowels here a e i o u
0:35
and also in capital letters as well so
0:38
these are different vowels here if you
0:40
want to remove all the vowels from a
0:43
sentence
0:45
then we have this python program which
0:48
is written right here if I execute this
0:50
Python
0:53
program you will see original string was
0:56
hello welcome to Python programming but
0:59
now string without vowels is you can see
1:03
E is
1:04
removed again e is removed o is also
1:07
removed so this is actually the output
1:10
here all
1:12
those characters are removed which are
1:15
vovel characters so you get this output
1:18
so this question is specifically program
1:21
is asked here so I will show you the
1:25
output what is this is a program here so
1:28
I will use a special program here which
1:30
is Python tutor which actually shows the
1:33
step-by-step execution of the program so
1:36
you can visualize it step by step
1:39
online so first of all we define this
1:42
function here which is in the global
1:44
frame which is remove vowels it actually
1:46
takes the actual sentence from which you
1:49
want to remove the vowel characters we
1:51
pass it as an argument now in the next
1:54
step we provide the input string right
1:56
here which is hello welcome to Python
1:59
programming so we now need to remove the
2:02
wobbles and now we are simply calling
2:04
this function here which is remove vels
2:06
and it actually takes the text as an
2:08
argument so we are simply calling this
2:10
function
2:12
so now we are defining all the vowels
2:15
inside this variable vowels so as you
2:18
can see all the vowels are stored so
2:20
that we can remove it from this
2:23
sentence so quite a number of different
2:26
ways you can do but I'm using the very
2:29
popular and the very simplest of way by
2:31
using a for loop and for this we need
2:34
separate variable to store the result so
2:37
for this we declare a result
2:40
variable where we will be storing the
2:42
output text and now we'll be using the
2:45
for
2:47
loop so we will do this for each and
2:50
every character we will be comparing it
2:52
whether they are equal to these set of
2:55
characters so one by one we will do this
2:58
so for this that's why we are using for
3:00
loop so for every character in this text
3:04
that we got we will loop through so we
3:07
will come to the first character so the
3:10
first character as you can see is h h is
3:13
not equal to this
3:15
uh all these characters the wobbles h is
3:18
not a vowel so it will be added in the
3:21
result so this will be added here you
3:23
can see the execution of the program
3:25
again it will move to the next character
3:27
which is E e is a wobble so this
3:30
condition will
3:32
be not be executed so this E will not be
3:37
added in the result so it will move to
3:39
another L l will be added you can see
3:42
that again L will be added so you can
3:46
just see the control how the control of
3:48
the control flow is executed in the
3:51
program it will navigate to O o is also
3:55
present so O will be reflected comma is
3:59
not a vowel so comma will be added w
4:02
is not a vowel space also is added you
4:07
can see that so it will run for each
4:09
character here so let me just fast
4:11
forward it so you can see the output
4:14
coming right here step by step so it is
4:16
removing all the wobbles characters
4:18
which we defined in the wobbles variable
4:21
so it is just having this if condition
4:23
and this then it printed out the actual
4:27
result so the program is pretty simple
4:30
we simply use this for loop and just we
4:33
have this if condition you just
4:35
predefined all the vowels in this
4:36
variable so we are simply checking in
4:38
with this if condition if the then we
4:41
are adding the result
4:43
so thank you very much guys for watching
4:45
this video and also check out my website
4:49
freemediatetools.com
4:50
uh which contains thousands of tools
#Programming
#Scripting Languages