Anti vowel . what is wrong with my code?


#1

Define a function called anti_vowel that takes one string, text, as input and returns the text with all of the vowels removed.

For example: anti_vowel("Hey You!") should return "Hy Y!".

Don't count Y as a vowel.
Make sure to remove lowercase and uppercase vowels.

my code

def anti_vowel( text ):
for i in text :
if i =="a" or i=="e" or i=="i" or i=="o" or i=="u" or i =="A" or i=="E" or i=="I" or i=="O" or i=="U":
text = text.replace(i,"")
return text
print text

my code only works on first word


#2

We cannot see this variable in global scope.

This method does not need to be in a conditional. For practice, try doing this exercise without using a built-in.


for i in 'aeiouAEIOU':
    text = text.replace(i)
return text

#3

didnt understand what you said.
can you explain it better thanks


#4

To repeat, for practice try doing this exercise without using .replace(). Keep the above example for future reference. If you cannot fix your own code, then it means you do not fully understand what should be happening.

We learn more by doing things from scratch, and getting a feel for how to write an algorithm.


#5

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