I want to call the description on weather api using python but it gives me this error when i put the code, but i search everywhere and i cant see it.
heres the code
des = response['weather']['description']
print("Description = ",des)
but im getting this error
TypeError: list indices must be integers or slices, not str
CodePudding user response:
Using this will fix it:
des = response['weather'][0]['description'][0]
print("Description = ",des)
Hope this helps!
NOTE:
Next time add your JSON code to the post to make stuff easier.