PlainError

TypeError: 'NoneType' object is not subscriptable

Last checked 2026-10-26 · 2 fixes · reviewed answer

TL;DRYour code tried to read a specific item from a list, dictionary or similar structure, but the thing it was looking at was empty (None) instead of actual data.

Most likely cause: A function returned None when the code expected a list or dictionary

Try first: Find the exact line causing the error

Likely causes

  1. A function returned None when the code expected a list or dictionarymost likely
  2. A variable was never assigned a value before being used with brackets like [0] or ['key']possible
  3. An earlier operation that should have created the data structure failed silentlyless likely

How to fix it

Safest first: SafeChanges settingsDangerous
  1. Find the exact line causing the errorSafe

    Look at the traceback and note the line number and variable name that is being subscripted.

  2. Trace where that variable comes fromSafe

    Check the function or line that assigned the variable and add a check to see if it is None before using it.

If that didn't fix it

Add a temporary print statement right before the error line to show the variable's value and type.

When to see a technician

If the error occurs inside a large or unfamiliar codebase, ask the original developer or a programmer familiar with the project for help.

Quick answers

What does TypeError: 'NoneType' object is not subscriptable mean?
Your code tried to read a specific item from a list, dictionary or similar structure, but the thing it was looking at was empty (None) instead of actual data.
What causes TypeError: 'NoneType' object is not subscriptable?
A function returned None when the code expected a list or dictionary. (most likely) A variable was never assigned a value before being used with brackets like [0] or ['key']. (possible) An earlier operation that should have created the data structure failed silently. (less likely)
How do I fix TypeError: 'NoneType' object is not subscriptable?
Try these in order, safest first: 1. Find the exact line causing the error. 2. Trace where that variable comes from.
What if that didn't fix it?
Add a temporary print statement right before the error line to show the variable's value and type.
When should I see a technician?
If the error occurs inside a large or unfamiliar codebase, ask the original developer or a programmer familiar with the project for help.
Did this fix it? Report a problem

Related errors

All Coding errors →