Error with Slider

Hello,

Sometime this error occurs.
This happened by the scenario “CHN_Sha-10_1_T-1”

By other scenarios this error didn’t occur.
What can I do to avoid this one?

TypeError Traceback (most recent call last)
in
2
3 # use the slider to have at look at every time step of the planned trajectory
----> 4 widgets.interact(draw_state, t=widgets.IntSlider(min=0,max=result_path[-1].time_step,step=1,value=0))

TypeError: ‘NoneType’ object is not subscriptable

Hi Max,
The error arose due to subscripting result_path, which is a NoneType here, and that further implies you did not find a feasible solution for this scenario to be displayed.

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 favourite 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 .

The error is self-explanatory. You are trying to subscript an object which you think is a list or dict, but actually is None. This means that you tried to do:

None[something]

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.