Intellipaat Back

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

I'm getting the following python error:

 File "em_sep.py", line 13, in <module>

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

TypeError: string indices must be integers, not str

Line 13 of the the code:

 email_s.append(email_1["email_address"])

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.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...