Python – TypeError: ‘long’ object is not iterable

python, python-2.7

I have just created a dictionary in python.

stb_info = self.stb_type()print type(stb_info) #The output gives me dict

When I want to run my tread function for each group

for group_no, shelves in stb_info:    self.thread_function(group_no, shelves)

I am getting the following error:

TypeError: 'long' object is not iterable

So, how I can solve this bug?

Best Solution

Try stb_info.items(). Just iterating over a dict iterates over its keys, so it's trying to unpack a key (a long) into two parts, which isn't possible.