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 -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -