Getting values from JSON file
<p>I am trying to get the values from count and add them to find the total sum.
The code I have written is:</p>

<pre><code>import json
data= '''
{
  "note":" sample data ",
  "comments":
  [
    {
      "School":"UCLA",
      "count":97
    },
    {
      "School":"MIT",
      "count":97
    },
    {
      "School":"Rutgers",
      "count":90
    }
  ]
}'''

number=list()
a=0
b=0
info = json.loads (data)
print json.dumps(info, indent=4)
for i in info:
    number= i["comments"][0]["count"]
for n in number:
    a=float(n)
    b+=a
print b
</code></pre>

<p>When I execute this, the output I am getting is:</p>

<pre><code>Traceback (most recent call last):
  File "testty.py", line 28, in &lt;module&gt;
    number= i["comments"][0]["count"]
TypeError: string indices must be integers
</code></pre>

<p>Can some one please tell me what I am doing wrong and how to fix it.</p>

<p>Thanks</p>