TypeError: list indices must be integers or slices, not str... again

So, I have this -

    hours = data['hours']

but when I run the code that it is in I get this error -

hours = data['hours'] TypeError: list indices must be integers or slices, not str

Full Code - Reddit - Full Code · GitHub

API Response - response.json · GitHub

The error explains that you cannot index a list using a string. So data must be a list type. You should double check the name data where data is created/loaded/changed etc. (print or similar is helpful) as it is not the type you expect.

1 Like