teamviewer.com link icon
or
Ask The Community

TeamViewer is one of the winners of the European Customer Centricity Award 🥳


Please find more information here.

TypeError: string indices must be integers

I need a way to get all the device data at one time in python. Here is what I am using so far'

for k in dictData.items():
print(dictData['devices'][0]['device_id'][k]) #TypeError: string indices must be integers
print(dictData['devices'][1]['alias'][k])

I also tried this
print(dictData['devices'][1]['alias'][0:5])

No go.

Thanks in advance and apologies for the earlier confusion!

Best Answer

Answers

  • RlS
    RlS Posts: 15

    Thanks!! That does it

  • jefryarch
    jefryarch Posts: 1 Newbie

    TypeError: means that you are trying to perform an operation on a value whose type is not compatible with that operation. If you are accessing items from a dictionary , make sure that you are accessing the dictionary itself and not a key in the dictionary. TypeError: string indices must be integers has been caused because you are trying to access values from dictionary using string indices instead of integer.