Why does my code wont work?


#1

def anti_vowel(text):
word = " "
for i in text:
while i not in "aeuioAEUIO":
word = word + i
i += 1
return word

Oops, try again. Your function crashed on Hey look Words! as input because your function throws a "cannot concatenate 'str' and 'int' objects" error.


#2

Okay so where you used a while loop, I actually think an if statement is better. The if statement is already inside of a loop, but when you're just starting loops, nested loops are hard to get the hang of and to understand. You would want to write if each in "aeiouAEIOU": in place of

and then say pass, because there is a vowel, and then just say else, word += i. Lastly, don't forget to return word, (which you didn't forget, so don't worry).


#3

Try this one instead
if i not in "aAeEiIoOuU":


#4

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