Python - Understanding errors
Code Life
By Pierre Marsaa
What Are Errors in Python?
When you write Python code, you'll encounter errors. Don't worry - errors are not bad! They're actually Python's way of helping you understand what went wrong.
Think of errors like a Codémon trainer giving you feedback: "Hey, you can't make a Codémon fly without wings!" Similarly, Python tells you: "Hey, you can't divide by zero - that doesn't make sense!" or "Hey, I don't know what is this variable you're talking about!"
↗️
Loading editor...
↶
↷
When you run this code, Python will show an error message. This is good - it's telling you exactly what's wrong so you can fix it!
Errors are displayed in english, and usually you want to read them from bottom to top, as the last line is often the most relevant one.
On the code above, the error message would say something like "NameError: name 'codemon_levl' is not defined". This means that we never attributed a value to 'codemon_levl', and yet, we're trying to print it.
Errors Are Your Friends
Every programmer encounters errors, even experienced ones! The difference is that experienced programmers have learned to read and understand error messages quickly. By learning about errors now, you're building an essential skill.
Verify