If you want to return a string, then you will need to join the list with an empty string as separator in the final return statement. The first return statement should be removed. That’s the one you are seeing as output.
Is it necessary to build a list from the string? Could we not utilize the built in
list() function to convert it?
Be sure your test phrase contains lots of duplicate vowels seeded throughout. That will give you something else to work out. Notice that
.remove() only takes out the first one it encounters? How will you make it greedy (global)?
anti_vowel with remove
You will come up against three powerful concepts towards the end of this track…
filter => one of Python's iterators
lambda => the anonymous function
and ternary expressions which are very handy if-else constructs that save a lot of coding when they make sense.
In addition we have default parameters to take into account. They give us added horsepower.
def filtre(text, flag=False, case='aeiouAEIOU'):
return ''.join(filter(lambda c: c in case if flag else c not in case, text))
For now, stick to what you are learning. This will come to pass, but now is probably not the time to press it. We’re only giving you a sneak peek.