SYNTAX- Error:list indices must be integers, not str in the error

Why is print student[‘name’] and not students[‘name’]
It says that list indices must be integers, not str in the error

because students is a list, while student (assuming the use of a loop) will hold each individual student, which is a dictionary. to look up a value in a dictionary, we use keys (like 'name'), while a list we can access by index (0 for example, for the first element in the list)


it says because the array have to be of type integers because string is an array indeed itself .
Indices are number that keeps in mind the position of the elements in the array. so when of type string there are many characters in it that have to be saved in some memory location.

The error is occurring because students must be initialized to a dictionary ({}) rather than a list () so you can add elements to it

List indices can only be integers
What you need is a dictionary .