9.6. Asking Good Questions

If you still cannot find the bug in your code after using the strategies outlined in this chapter, do not hesitate to reach out to other programmers.

Whether you are asking your teacher, another student, Google, or a rubber duck, you should first be able to answer the three questions outlined below.

Not only will these questions help others assist you more effectively, but they might just lead to discovering the answer yourself!

9.6.1. What is the problem with your code?

Describe the error you are experiencing with as much detail as possible.

Bad: “My program is broken.”

Bad: “I’m getting this error.”

Good: “There is a NameError on line 23, but it’s not clear to me what’s causing it.”

9.6.2. What have you done to try to fix the problem?

Another programmer can learn a lot of information by hearing what you have already tried.

Bad: Asking for help immediately.

Bad: Using trial and error without any specific direction.

Good: “I converted the user input to an integer, but I’m still seeing the problem.”

9.6.3. Where have you looked for an answer?

Bad: “I haven’t looked online or checked the class book at all.”

Bad: “I Googled the error message and didn’t see anything.”

Good: “I Googled ‘python list index out of range error’ and found a question on StackOverflow that seemed similar to mine. I tried that solution, but it didn’t fix my problem.”

A comic with the caption, "If debugging is the process of removing software bugs, then programming must be the process of putting them in."