Help with 'Disemvowel Trolls' kata on Codewars?

This challenge is to remove every vowel in a string. Here is my code so far:

def disemvowel(string_):
    for letter in string_:
        if letter in 'aeiouAEIOU':
            return string_.replace(letter, '')     

It fails every test because it only removes some of the letters that are vowels. For example,

‘Ths webste s for losers LOL!’
should equal
‘Ths wbst s fr lsrs LL!’

My code removes the I’s and but keeps the O’s and E’s. I believe the problem is that my code checks only for the first instance of a vowel and then removes that letter from the string and calls it a day. How do I get my code to keep checking every letter even after it finds the first vowel?

First clue, return in a loop.

1 Like