Generally, you should use isinstance() for type comparison.  Failing that, `if type(prediction) is dict:` would be better.