TypeError: 'NoneType' Object Is Not Subscriptable
The error: names = curfetchone()[0] TypeError: 'NoneType' object is not subscriptable. I tried checking the indentation but still there's an error. I read that maybe the variable
Solution 1:
If, due to whatever reason (empty result set?) curfetchone()
returns None
, a [0]
access is of course forbidden (as the error message clearly says).
So better do that in two steps and do
row = curfetchone()
if row is not None:
names = row[0]
# proceed
else:
# act appropriately
Post a Comment for "TypeError: 'NoneType' Object Is Not Subscriptable"