Error Handling · Lesson 48 of 76
Common errors
You'll meet the same handful of errors again and again. Knowing them by name saves time:
- SyntaxError — a typing-rule mistake (missing
:or)). - NameError — a name that doesn't exist (often a typo).
- TypeError — mixing types that don't go together, like text plus number.
- IndexError — asking for a list position that isn't there.
- KeyError — asking a dict for a key it doesn't have.
Python
Run it: that's an IndexError. Read the last line, and the fix is usually quick.
Your turn: change 5 to a valid position (0, 1, or 2) and run it.
You’re reading for free. Sign in to keep your progress and earn a certificate when you finish.Sign in to keep my progress →