Read Python Like a Pro / Errors and help
Lesson 7 of 10
The most common errors
Most beginner bugs are one of a handful: SyntaxError (typo in the code's shape), NameError (name doesn't exist), TypeError (wrong type), IndexError (list position too big), KeyError (missing dictionary key) and IndentationError.
Key points
- NameError: check spelling and that you defined it
- IndexError: lists start at 0
- IndentationError: line up your blocks
colors = ["red", "green"]
print(colors[2])Your turn
Write one tiny program that causes each of NameError, IndexError and KeyError. Read each message carefully.
Quiz · +10 XP
Which error does this raise?
Log in to save progress and earn XP.