Why does anti_vowel fail in some cases?


#1

Question

Why does anti_vowel fail in some cases?

Answer

The most common issue is returning too soon. If you’ve indented a return to be inside of a loop, that causes problems because if it’s executed, the function exits immediately and returns whatever value is there.
Be sure to return your final result outside of any loops at the end.


FAQ: Learn Python - Practice Makes Perfect - anti_vowel
#2

2 posts were split to a new topic: Anti-vowel attempting to use remove


#3

Hello I am having trouble with this assignement, my code looks like this :

def anti_vowel(text) :
  result = list(text)                # I want to work with a list
  for l in result :                  # For every item of the list
      if l in "AEIOUaeiou" :         # I check if it is a vowel
        result.remove(l)             # If it is I remove it
  return "".join(result)
  
print anti_vowel("ecureuil")         # returns "crul"  
print anti_vowel("urluberlu")        # returns "rlbrl"
print anti_vowel("Un Grand bAteAU")  # returns "n Grnd btA"
print anti_vowel("Hey lOOk words!")  # returns "Hy lOk wrds!"

Could someone tell me what I am doing wrong? Thank you in advance!

PS: Pardon my french


#4

can you see the split i made in this post/topic:

i named the new topic anti-vowel attempting to use remove, hey, what a coincidence, that is what you attempted, did you checkout this topic? That is the whole point of FAQ, to not having to repeat our selves.