TypeError: list indices must be integers or slices, not str
This error is usually caused when you try to access an element in a list using a string as the index, rather than an integer. For example:
my_list = [1, 2, 3]
print(my_list['a']) # This will cause the TypeError
To fix this, you should use an integer to index the list, like this:
Watch a video course
Python - The Practical Guide
If you want to access the elements of a list using a string key, you should use a dictionary instead of a list. Dictionaries are data structures that allow you to map keys (which can be strings or any other immutable type) to values.
For example: