How to remove all the vowel character from a string?


#1

I am a green hand at programming so I may make so really stupid mistakes.

I want to remove all the vowel character from a string. The below is what I have written.

Instead of returning print “bcdf”, it prints “aeioubcdf”.

```python

n = “aeioubcdf"
def anti_vowel(text):
for i in text:
if i in “aeiouAEIOU”:
text = text.replace(“i”,”")
else:
text = text
return text
print anti_vowel(n)

Can someone please tell me what’s the problem with my code?
Thanks in advance.

<do not remove the three backticks above>

#2

text = text.replace("i","")

consider what is i here?is i a variable or string?


#3

I see. Thank you so much!


#4

btw may I ask to indent in the editor here? This is my first time posting here. I am not so familiar with that


#5

Have a look at this topic it’ll help you to make a good topic :slight_smile:


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.