# Anti_vowel (text)

#1

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>
It doesn’t stop compiling.
<What do you expect to happen instead?>
I think that the code should run or at least give me an error.

``````def anti_vowel(text):
result = []
a = len(text)-1
b=1
while b <= a:
if (text[b]!= 'a' and text[b]!='a'and text[b]!='e'and text[b]!='E'and text[b]!='i'and text[b]!='I' and text[b]!='o' and text[b]!='O' and text[b]!='u'and text[b]!='U'):
result.append(text[b])
b = b+1
return "".join(result)
``````

#2

`b` is only increased by one when `text[b]` is a vowel, but `b` should be increased in all cases, otherwise the loop will never evaluate to false

you have what is known as in a infinity loop

#3
``````def anti_vowel(text):
result = []
a = len(text)-1
b=1
while b <= a:
b = b+1
if (text[b]!= 'a' and text[b]!='a'and text[b]!='e'and text[b]!='E'and text[b]!='i'and text[b]!='I' and text[b]!='o' and text[b]!='O' and text[b]!='u'and text[b]!='U'):
result.append(text[b])

return "".join(result)
``````

I tried this and it didn’t work.

#4

you can’t increase `b` before the if condition. This means the first letter will be skipped, it `b has to be after and outside the if clause

in your case, the first two letters are currently skipped because `b` has an initial value of `1`, while strings indexes start at zero

#5

Thank you it worked

def anti_vowel(text):
result = []
a = len(text)-1
b=0
while b <= a:
if (text[b]!= ‘a’ and text[b]!='A’and text[b]!='e’and text[b]!='E’and text[b]!='i’and text[b]!=‘I’ and text[b]!=‘o’ and text[b]!=‘O’ and text[b]!='u’and text[b]!=‘U’):
result.append(text[b])
b = b+1

``return "".join(result)``

#6

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