Anti_vowel condensed?


#1

I am getting the correct results, but is there a way to condense the if statement I am using so that I don't I have to repeat 'and letter !=..."""?

def anti_vowel(text):
no_vowel = []
for letter in text:
if letter !="e" and letter !="o" and letter !="i" and letter !="a" and letter !="u" and letter !="A" and letter !="E" and letter !="I" and letter !="O" and letter !="U" :
no_vowel.append(letter)
return ''.join(no_vowel)


#2

Yes, considerably condense with the not and in operators and a vowel string.

if x not in "aeiouAEIOU":

#3

Of course! Brilliant. Thanks


#4

Now that I noticed it, the answer was right there in the hint that was given on the sidebar the entirety of the time. Always check the hint and experiment with what the hint says.


#5

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