What to do in Python error when trying to access list by index - “List indices must be integers, not str”?
To get rid of this error you can use the below-mentioned code:-
>>> player=[1,2,3]
>>> player["score"]
Traceback (most recent call last):
File "", line 1, in
TypeError: list indices must be integers, not str
>>> player={'score':1, 'age': 2, "foo":3}
>>> player['score']