Try it:

Find and fix common errors in your code

Syntax errors: Find and fix common errors in your code

Usually in the try it section you get code that just works but this tutorial is all about debugging errors, so the code below has 4 common mistakes, each with instructions on how you can fix them.

Press Ctrl + Enter to run the code.

Click on your score in the top right corner of the code editor to see what your code needs to do.

Any line of code that starts with a #  is a comment: it doesn’t affect how the program runs, it’s just there to help explain what the code does.


  1. Change line 3 to add the missing ”

    Remember that you have to balance brackets and quotes. This means that the number of times you start a new quote / set of brackets should be the same as the number of times you end them.

  2. Check capital letters on line 5

    Remember that python throws an error at you if it finds capital letters where it’s not expecting them or if you spell something wrong.

  3. Add the missing brackets on line 7

    Remember that every ( should be balanced with a )

  4. Fix the indentation on line 9

    You can indent code (move it to the right) by pressing Tab and you can unindent it (move it to the left) by pressing Shift + Tab

    You can select more than one line at a time and use these shortcuts too which can save loads of time.

On the next page you’ll get some code examples that have been deliberately broken for you to try to fix.


KPRIDE stands for Keywords, Predict, Run, Investigate, Debug and Extend and it’s a way of helping you explore and understand python code. Click on the image below for a set of KPRIDE activities for this python skill.KPRIDE

Page 1: Intro

Page 2: The theory: learn what you need to know as fast as possible.

Page 3: Try it: try out and adapt some working python code snippets.

Page 4: Debug it: Learn how to find and fix common mistakes.

Page 5: Extend it: Choose a project idea to use your newfound python skills.