How can I correctly parse a JSON response in Python to avoid index errors