The result doesn't make sense


#1

Hi, I have a problem that I can't understand. I was on the anti_vowel exercise, and it came the result like this:

Can anyone explain why I got this result for me? thanks a lot!


#2

Hi, @ryanlin0709 ,

Often, a good way to find a bug in a program is to insert a temporary print statement so that you can observe the values of variables.

After this statement in your if block ...

result = text.replace(c,"")

... insert ...

print c, result

Use appropriate indentation to make the print statement part of the if block.

Then, at the end of your code, add a statement such as this that calls the anti_vowel function ...

print anti_vowel("Hey look Words!")

You should also look at the documentation for the replace method to make sure you know what it does.

Let us know if this helps you find the problem.


#3

Hi @appylpye ,

Thanks for your help! It's a useful tip for me to find a bug for my program. Actually, I found that there was a mistake that I should use the argument "text" rather than the argument "result". Thanks again!


#4

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