Find it fast
Read · 1 of 3
Look inside
When the output is wrong but nothing crashes, add a print where you suspect the problem and look at the real values. They're often not what you assumed.
If you don't know where to look, check halfway through: if the values are right there, the bug is later; if not, it's earlier. Halve again.
Read this lesson as text
Print what the code is thinking, and narrow down where it goes wrong.
Look inside
When the output is wrong but nothing crashes, add a print where you suspect the problem and look at the real values. They're often not what you assumed.
If you don't know where to look, check halfway through: if the values are right there, the bug is later; if not, it's earlier. Halve again.
Exercise: Wrong count
This should count the vowels in a line, capital or small. It runs, but the answer is sometimes wrong.
Exercise: Removing while looping
This should print the numbers with every even number removed. It works for some inputs. Find out why it skips some, and fix it.