Python Forum
NoneType' object is not subscriptable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NoneType' object is not subscriptable
#10
This error means that you attempted to index an object that doesn’t have that functionality. You might have noticed that the method sort() that only modify the list have no return value printed – they return the default None. ‘NoneType’ object is not subscriptable is the one thrown by python when you use the square bracket notation object[key] where an object doesn’t define the getitem method . This is a design principle for all mutable data structures in Python. You can reproduce TypeError that you get in your code if you try this at the Python command line:

None[0]

None has a special status in Python. It is a favorite baseline value because many algorithms treat it as an exceptional value, used in many places in the language and library to represent the absence of some other value .
Reply


Messages In This Thread
RE: NoneType' object is not subscriptable - by irvinborder - Aug-06-2020, 05:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  AttributeError: 'NoneType' object has no attribute 'all' synthex 2 5,311 Mar-07-2019, 11:11 AM
Last Post: synthex
  TypeError: 'method' object is not subscriptable ayaz786amd 1 39,314 Nov-24-2018, 11:16 AM
Last Post: j.crater

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020