Errors
Traceback (most recent call last):
File "/home/mjs/test.py", line 2, in
<module>
sleep ("10")
TypeError: an integer is required (got type str)
Types of error
There are three types of error that can occur in a program: syntax errors, runtime errors, and semantic errors. The first is fairly simple to detect in any common programming interface. The second may be easy to spot, but this depends on the actual error. The last might be difficult to spot, but doing so gets easier with practise.Syntax errors
These occur when the programmer doesn’t follow the rules of the programming language. Sometimes the programming environment will simply refuse to even try and run the program.Missing colon
Here is an example of a fairly simple syntax error in Python. The programming environment, in this case Mu, caught the error and refused to try and run the program.<img src="https://rpf-futurelearn.s3-eu-west-1.amazonaws.com/block-to-text2/Screenshots/fl-b2t-w2-step02-missingcolon.gif" alt="Animated gif of code missing a colon being run. The first line of the code states for i in range (10). The error message states: File "/User/matthogan/mu_code/b2t 26.py", line 1for i in range (10) with an ^ under the bracket. The next line of the error message states SyntaxError : invalid syntax”>The line where the problem has occurred is given in the error message and a
^
is used to indicate the position of the error. In this case, there’s a colon missing after the )
on line one.Additional bracket
Here’s another common error that is easily caught:
Missing bracket
This one can be a little trickier.
Incorrect quotation mark
In this example the programmer has used a double quotation mark matched with a single quotation mark. Quotation marks should be the same around a single string — they are not interchangeable.
Debugging discussion
Debugging becomes easier as you become more familiar with the Python language and understand the common errors you make.- How would you introduce debugging to learners new to text-based programming? Share your thoughts in the comments.
Scratch to Python: Moving from Block- to Text-based Programming

Our purpose is to transform access to education.
We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.
We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.
Learn more about how FutureLearn is transforming access to education