# Oops, try again. Your function fails on anti_vowel("Hey look Words!"). It returns "H" when it should return "Hy lk Wrds!"

#1

Oops, try again. Your function fails on anti_vowel("Hey look Words!"). It returns "H" when it should return "Hy lk Wrds!".

``````def anti_vowel(text):
longtext = ""
for item in text:
if item != "a" or "A" or "e" or "E" or "i" or "I" or "o" or "O" or "u" or "U":
longtext = longtext+item
return longtext``````

#2

I believe your return just needs to be brought out of your for loop.

#3

I'm not so sure. I tried out your code with a fixed return statement and it did not work, I believe.
Looking at my code then yours, you need to use lists, one called vowels, which is the vowels, and an empty list called anti.

``````vowels = ["A", "a", "E", "e", "I", "i", "O", "o", "U", "u"]
anti = []``````

Then your loop should be like this:

`````` for i in text:
if i in vowels:``````

And end it with an else statement. I think you can go from there.

#4

Here's how I did it with some help from another thread (Because I too had got some things wrong in this exercise):

``````def anti_vowel(text):
removal = ""
vowels = ['a','e','i','o','u','A','E','I','O','U']
for i in text:
if i not in vowels:
removal = removal + i
return removal

print anti_vowel('Hey there! how you doing?')``````

#5

Can you help me solve the is_prime problem?

here's the error: Oops, try again.
Your function fails on is_prime(2). It returns None when it should return True.

here's my code:

``````def is_prime(x):

if x>1:
for n in range(2,x):
if (x%n ==0):
return False
else:
return True

else:
return False

``````

#6

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