Lazo Lab Sign up

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.

Watch a video on thisOpens YouTube search results for “The most common errors” in a new tab

Quiz · +10 XP

Which error does this raise?

Log in to save progress and earn XP.