8/15 how to replace something with nothing while keeping the string?


‘def anti_vowel(text):
for x in text:
if x in “aeiouAEIOU”:
return x’


error message unknown, trying to fix it finding how to skip/replace the letter with blank


Hi @blogcoder18203,

In order to help you, we’re going to need a few things:

  • A link to the lesson
  • Your formatted code
  • Any and all error messages you have received


Are you sure you want to return a single letter? Wouldn’t one need to complete iteration of the entire string before returning the revised version (sans vowels)?


how? i understand that i am going through only one letter, but it s in a for loop, and i am very confused why it is happening.


x is a single letter representation. Your code is saying to return it (the letter) if it is found in the vowel string. That means your function will terminate upon the first vowel found. We need to return only consonants, in a nearly complete word.


‘def anti_vowel(text):
for x in text:
if x in ‘aeiouAEIOU’:
return tex
’ maybe
should i just get the answer


Strings are immutable so this will have no effect. However, you could try,


since tex is a list, and .remove() is a list method. This way text is not changed and iteration can continue with no issues.


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