TypeError: string indices must be integers, not str // working with dict

前端 未结 3 484
醉酒成梦
醉酒成梦 2020-12-14 05:38

I am trying to define a procedure, involved(courses, person), that takes as input a courses structure and a person and returns a Dictionary that describes all t

3条回答
  •  悲哀的现实
    2020-12-14 06:34

    time1 is the key of the most outer dictionary, eg, feb2012. So then you're trying to index the string, but you can only do this with integers. I think what you wanted was:

    for info in courses[time1][course]:
    

    As you're going through each dictionary, you must add another nest.

提交回复
热议问题