Step 4: Repeat
00:00 In the previous lesson, you identified a possible error, and you made a change. Now you’re on step four of the debugging steps, where you will repeat steps one to three as needed until the code works as expected.
So keep stepping through this and see what happens to your
new_word variable. And this is looking great. It keeps adding each letter of the word, separated by an underscore, just as you wanted to. Let’s go to the end of the program,
01:20 and you can see that the expected output appears in your interactive window. That’s great. You had a success. Everything works as expected. So in this case, your first attempt at fixing the bug worked, so you don’t need to repeat steps one to three anymore. This won’t always be the case.
01:47 So in the last four lessons, you went through all the four debugging steps: started by guessing which section may contain the bug, set the breakpoint and inspected the code by stepping through it with your debugger, then you identified the possible error and made a change, and in this case, the change actually fixed the bug, so you didn’t need to repeat steps one to three because your code already worked as expected. These debugging steps are really helpful to keep in mind.
02:13 Use them as your blueprint for approaching any bugs that you run into while coding up your own programs. But what should you do if you don’t have access to a debugger? In the next lesson, you’ll take a look at an alternative way of debugging that you can do also if you don’t have access to a debugger.
Become a Member to join the conversation.