Python Forum
TypeError: 'NoneType' object is not subscriptable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: 'NoneType' object is not subscriptable
#3
(Sep-26-2020, 07:44 AM)syafiq14 Wrote: TypeError: 'NoneType' object is not subscriptable

The error is self-explanatory. You are trying to subscript an object which you think is a list or dict, but actually is None (i.e: the object has no value). This means that you tried to do:

None[something]

Here 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. This is a design principle for all mutable data structures in Python.

This ‘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.
buran write Sep-19-2022, 07:06 AM:
Necroposting with sole purpose to advertise your site is not acceptable. Link removed.
Reply


Messages In This Thread
RE: TypeError: 'NoneType' object is not subscriptable - by cristydavidd - Sep-19-2022, 05:04 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  TypeError: cannot pickle ‘_asyncio.Future’ object Abdul_Rafey 1 487 Mar-07-2024, 03:40 PM
Last Post: deanhystad
  error in class: TypeError: 'str' object is not callable akbarza 2 583 Dec-30-2023, 04:35 PM
Last Post: deanhystad
Bug TypeError: 'NoneType' object is not subscriptable TheLummen 4 802 Nov-27-2023, 11:34 AM
Last Post: TheLummen
  TypeError: 'NoneType' object is not callable akbarza 4 1,114 Aug-24-2023, 05:14 PM
Last Post: snippsat
  [NEW CODER] TypeError: Object is not callable iwantyoursec 5 1,496 Aug-23-2023, 06:21 PM
Last Post: deanhystad
  Python: Regex is not good for re.search (AttributeError: 'NoneType' object has no att Melcu54 9 1,622 Jun-28-2023, 11:13 AM
Last Post: Melcu54
  TypeError: 'float' object is not callable #1 isdito2001 1 1,125 Jan-21-2023, 12:43 AM
Last Post: Yoriz
  TypeError: a bytes-like object is required ZeroX 13 4,382 Jan-07-2023, 07:02 PM
Last Post: deanhystad
  Help with python 'not subscriptable' error Extra 3 2,198 Dec-16-2022, 05:55 PM
Last Post: woooee
  TypeError: 'float' object is not callable TimofeyKolpakov 3 1,535 Dec-04-2022, 04:58 PM
Last Post: TimofeyKolpakov

Forum Jump:

User Panel Messages

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