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 isnotNone:
names = row[0]
# proceedelse:
# act appropriately
Post a Comment for "Typeerror: 'nonetype' Object Is Not Subscriptable"