All right, exercise number five.
If we look at the output, it seems like we want to get some kind of pyramid that skips every second
row and prints the letter that follows.
Let's hope the code that we have print anything remotely similar.
And what the heck is this?
We definitely have our work cut out for us.
OK, where do we start?
You know what?
I have no idea.
So I'm going to do is just place a bunch of break points and just try to see why this code is behaving
the way that it is.
OK, so the first part of the outer loop is one, I imagine this two is not zero skipping the statement
and as soon as we enter the inner loop, A gets converted to another letter before it has the chance
to get printed.
That's not right.
If you look at the output, we need to print the letter A..
So what I'm going to do is start by moving this after the print function.
All right, let's try again.
OK, just not smaller than I, so it prints the letter A, OK, and now if I look back at the output,
I need to start a new line, but this inner loop is going to run ten times before the next new line,
which is not what we want to do.
So right there, by visualizing the runtime using breakpoints, I've already identified the second bug.
So once again, the amount of times the inner loop runs depends on the outer loop index, not a static
value of ten.
So we'll change that.
And OK, I think we might be on to something.
Let's run the code.
Hmm, it's skipping a whole lot of letters that can't be good.
Let's relaunch the debugger.
OK, we're fine here.
So at this point, I equals two and it's about to set this run.
Equals three.
Oh, I see every time it prints an empty space, it also increments the letter.
So this line should be in the outer loop, not the inner loop.
All right, restart the debugger.
Prince, the letter A.
Skips the next one.
And that's all.
Good job on debugging, exercise number five.
This was definitely not an easy one to debug, but we made it.