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
- Function returned None unexpectedly
- Missing return statement
- Failed lookup (dict.get returned None)
- Uninitialized variable
Fixes
- 1. Check for None before indexing
if result is not None: x = result[0] - 2. Use .get() with default
value = d.get('key', default) - 3. Add return statement
def foo(): x = compute() return x # was missing
Still not fixed?
- • Search the exact error message on Stack Overflow or GitHub Issues
- • Check the official docs for the language or tool
- • Ensure your versions (Node, Python, npm, Docker) are up to date
- • Try in a minimal reproduction (new project, single file)
Related Errors
DuskTools That Might Help
All Errors
JavaScript Heap Out of MemoryModuleNotFoundErrorAddress Already in UseIndentationErrorCannot Find ModulePeer Dependency WarningCORS Policy BlockedMerge ConflictDocker Port Already AllocatedENOENT: No Such File or DirectoryKeyErrorMaxListenersExceededWarningRecursionErrorDetached HEAD StateEACCES: Permission DeniedValueErrorNo Space Left on DeviceERR_REQUIRE_ESMFileNotFoundError