python - 'set' object has no attribute '__getitem__' -


i have dictionary name typecontext , have list named types. want take 5 elements of types , add dict typecontext. getting error set attribute has no object getitem.

 try:     k=0     typecontext = dict()     in range(0, len(types), 5):         print(i)         if + 5 < len(types):             typecontext.update({'item_'+str(k) :types[i:i + 5]})         else:             typecontext.update({'item_' + str(k): types[i:len(types)]})         k=k+1 except exception e:     print(e) 

it looks variable types set object. when try slice error.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -