Traceback (most recent call last):
File “main.py”, line 24, in place_id = js[‘results’][0][‘place_id’]TypeError: ‘NoneType’ object is not subscriptable
The error is saying that your variable js is of type None, which is what you declared it to be in your try...except block. Therefore, there is some error with the json.loads(data) call you have.
There is little point to a try..except block if you are not getting the errors from it. Add a catch and print the error. It will help a lot.
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]
‘NoneType’ object is not subscriptable 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. This is a design principle for all mutable data structures in Python.
import numpy as np # Import numpy package for mathematical operations
defaddition1(arrays): # Function to perform addition
total1=arrays.sum(axis=1) # Row-wise sum in 2D numpy array
print('row wise sum',total1[0:4]) # Printing first 4 elements of total
a=np.arange(12).reshape(6,2) # Creating a 2D array
print('input array \n',a) # Printing a comment
print('*********')
addition1(a) # Calling the function