results = [
{"id": 1, "name": "ensheng", "score": 10},
{"id": 2, "name": "gengyang", "score": 12},
{"id": 3, "name": "jordan", "score": 5},
]

I want to find gengyang's score. This is what I tried :

>>> print((results["gengyang"])["score"])

but I got an error message instead :

Traceback (most recent call last):
  File "<pyshell#62>", line 1, in <module>
    print((results["gengyang"])["score"])
TypeError: list indices must be integers, not str

Any ideas how to solve this? Thank you ..
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to