Error: TypeError: 'NoneType' object is not subscriptable