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
Post a Comment