Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
in Machine Learning by (19k points)

I'm getting the following python error:

 File "", line 13, in <module>

    if ema_1["confidence_score"] == "50":

TypeError: string indices must be integers, not str

Line 13 of the the code:


1 Answer

0 votes
by (33.1k points)

Let's say 'time1' is the key of a dictionary, eg, feb2012. So you're trying to index the string, but you can only this with integers. 

For example:

for info in courses[time1][course]:

when you iterate through each dictionary, you must add another nest.

Hope this answer helps you!

If you wish to learn more about Machine Learning, visit the Machine Learning tutorial and Machine Learning Course by Intellipaat.

Browse Categories