Parsing Python dictionary with multiple objects

Rustom Mody rustompmody at gmail.com
Wed Oct 15 19:10:26 CEST 2014


On Wednesday, October 15, 2014 10:30:49 PM UTC+5:30, Anurag Patibandla wrote:
> keys = json.keys()
> order = list(keys)
> q1 = int(round(len(keys)*0.2))
> q2 = int(round(len(keys)*0.3))
> q3 = int(round(len(keys)*0.5))
> b = [q1,q2,q3]
> n=0
> for i in b:
>     queues = order[n:n+i]

>     n = n+i
>     lists = [(queues[j], json.get(queues[j])) for j in range(len(queues))] 

>     dicts = dict(lists)
>     print dicts
>     print dict[0]


> print dicts works as expected. It gives me the entire dictionary. But when I do dicts[0], there is the following error:
> 'type' object has no attribute '__getitem__'

Do you want dict[0] ??
I think you want dicts[0]



More information about the Python-list mailing list