‘NoneType’ object has no attribute whatever
Typically, you would get this from
something = get_answer() # ... lots of code if something.whatever() is 'cabbage': ...
something to be an object returned by
get_answer(), but for some reason, this function returned
None (perhaps because you fell off the end of the function without an explicit
None object cannot perform the function you are asking it to perform, because it basically has no methods at all.
It’s hard to give general guidance, but some common fixes include explicitly checking that the result is not
None, and using a
try: block which guards against terminating on this error.