8/15 anti_vowel


#1




My code works but the website keeps telling me my code returns "none" and for me to try again.


vowels = ("aeiouAEIOU")
def anti_vowel(text):
    linword = []
    for l in text:
        if l in vowels:
            pass
        else:
            linword.append(l)
    wholeword = ''.join(linword)
    print wholeword
    
anti_vowel("Hey look Words!")


#2

It's right, where do you see a return command?
Maybe instead of print wholeword you should return it.


#3

If I had a cookie I would give it to you.


#4

Ah, my favorite kind of response. :slight_smile:
Glad I could help, Happy New Years!


#5

you don't have to use lists for this.

here is my solution:

def anti_vowel(text):
  vowels = ["a", "e","i","o", "u"]
  new_text = ''
         for i in text:
             if i.lower() not in vowels:
             new_text += i
         return new_text

so, just create new empty string, and later check if any of the items (characters) from 'text' argument IS NOT any of the vowels. if character is not vowel, add him to newly created string. if character is vowel, the loop won't do anything, it will go on to the next item of the 'text'.

also, note the lower() method on each character from text argument. it's better to modify what you want to evaluate than to have a container with all variations of data, because if the task was the oposite - to remove all consonants, would you add all B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, X, Z and b,c,d,f,g,h etc..? :slight_smile: using lower() you change the character to lower case so you can match it with vowels list. note that doesn't change the "i" that you later pass to new_text. it's fine for this case where we have 10 characters, but just so you know for future, where you could have many varitations.

i hope i will get some cookie too. :slight_smile:


#6

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