Python

TypeError: 'NoneType' object is not subscriptable

TypeError: 'NoneType' Not Subscriptable

You tried to use [] or indexing on a value that is None.

Common Causes

Fixes

  1. 1. Check for None before indexing
    if result is not None:
        x = result[0]
  2. 2. Use .get() with default
    value = d.get('key', default)
  3. 3. Add return statement
    def foo():
        x = compute()
        return x  # was missing

Still not fixed?

Related Errors

DuskTools That Might Help

All Errors