5 Do Not Be Afraid of Breaking Things
- Understand that making mistakes is a normal, healthy part of learning Python
- Read and interpret basic Python error messages to find and fix bugs
- Learn how good setup habits protect your computer and files from unintended changes
5.1 Making Mistakes is Part of Coding
One of the biggest hurdles when starting out with Python is the fear of breaking something or getting an error. It is completely normal to feel cautious, but coding is very different from doing a physical laboratory experiment. In a lab, a single slip-up can waste hours of effort, ruin expensive materials, or spill chemicals.
In Python, making a mistake usually just results in a text message appearing on your screen. Nothing breaks physically, and your computer remains completely safe. In fact, triggering error messages on purpose is one of the fastest ways to learn how code works!
5.2 This Course Uses Our Training Machines
Throughout this course, you are working on our pre-configured training machines rather than your personal laptop.
This means you have a safe sandbox to experiment in. If you type the wrong command or get stuck, we can easily reset things for you. There is zero risk to your personal computer, files, or photos. Use this freedom to experiment, test new ideas, and type out code without worrying about making a mess.
5.3 Python Gives Useful Error Messages
Python code runs line by line. When Python encounters something it does not understand, it stops running and prints an error message to the screen. Rather than seeing an error message as a failure, think of it as a helpful clue.
Python tells you three key things:
- Where the problem happened (the line number).
- What kind of error occurred (the error name).
- Why it happened (a short explanation).
5.3.1 Example 1: A Syntax Error (A Typing Mistake)
If you forget to close a pair of quotation marks, Python cannot understand where your text finishes:
print("Hello world)What Python displays:
File "<stdin>", line 1
print("Hello world)
^
SyntaxError: unterminated string literal
- Line 1: Tells you exactly where Python got confused.
- The Little Arrow (^): Points to where the mistake occurred.
- SyntaxError: Means a rule of the Python language was broken (in this case, an unclosed piece of text).
This might sound like complete nonsense right now — and that’s fine. Terms like “SyntaxError” and “string literal” will start to make a lot more sense once you’ve learned a few more of the technical building blocks of Python, so don’t worry about memorising them just yet.
5.3.2 Example 2: A Name Error (A Spelling Mistake)
If you misspell a command name, Python will tell you that it does not recognise the word:
prnt("Hello world")What Python displays:
NameError: name 'prnt' is not defined. Did you mean: 'print'?
Notice how friendly this message is—Python even suggests the correct spelling (Did you mean: 'print'?)!
5.4 Learning from Your Mistakes
Every programmer, from complete beginners to senior software engineers, writes code that produces errors every single day.
When an error happens:
- Read the bottom line of the error message first.
- Check the line number Python points to.
- Look for small typos, missing brackets, or missing quotation marks.
By making mistakes, trying different options, and seeing what happens, you will quickly develop an intuition for writing clean Python code.
5.5 Good Habits Protect Your Files
Later in the course, we will explore how a good workspace setup helps protect your work. Rather than relying on “perfect coding” to avoid problems, programmers use simple rules to keep everything safe:
- Keep files inside your working directory: Working inside a single project folder ensures Python only touches files in that specific place.
- Never touch system files: By keeping your project separate from your computer’s main operating system files, your broader computer stays completely safe.
If you want to learn how to save and back up versions of your code so you can undo mistakes at any time, consider attending our course which introduce Git and Version Control.
5.6 Exercises
5.7 Summary
- Mistakes are normal: Making errors is an essential part of learning how to program.
- Low risk: Writing wrong code on our training machines will not damage your computer or lose personal files.
- Read the clues: Python error messages tell you the line number, the error type, and often suggest how to fix the problem.
- Good workspace habits: Keeping files inside your working directory ensures your projects stay clean, organised, and safe.