Step 1: Guess
00:00 In the previous lesson, you wrote out the buggy program and you took a look at what you expect the output to be and what the output really is. You also got to know that the debugging steps that you will follow for the rest of this course. In this lesson, you will get started with step number one, where you will guess which section may contain the bug.
00:31 The first step is to identify the section of code that likely contains the bug. You may not be able to identify exactly where the bug is at first, but you can usually make a reasonable guess about which section of your code has an error. So let’s try this here.
And you have a main code block that is at the bottom of your script, where you define the phrase
"hello" and then also call the
print() function and the
add_underscores() function, passing in the phrase.
Let’s take this one apart a little more. The first line in the function definition seems all right. You’re defining a new variable called
new_word and assigning it to an underscore as a string. You’re all good there.
So you can conclude that the problem is somewhere in the body of the
for loop. In the next lesson, you will set a breakpoint here and then start stepping through your code to see what’s going on in line 4 of your script.
Become a Member to join the conversation.