python check if key exists in dictionary and not none