Skip to main content

2.5) Fixing Your First Bug


A bug in programming jargon is an error in your code which causes the program to produce unexpected or incorrect result or behaviour.

You noticed here that Python did not print out the result of 2+3 like it did when we were writing code interactively. This is normal, but it’s not what we want. To make your program print the result of the operation you have to write:

[code lang="python"]
print 2+3
[/code]

If you don’t write the command “print” in a program that you execute, it will do the operation but it will not print out the result.

Correct your script and rerun your program. The output should be like this:

[code lang="python"]
>>> ================================ RESTART ================================
>>>
Hello, World!
5
>>>
[/code]

There you go, bug fixed!

As you can see here, when you run a program, Python executes each line, one after the other.