Accessing Python Dictionary

Just wondering if any one could help with the following error:
label_sample_dict= {0: 61, 1: 28, 2: 21, 3: 6, 4: 4, 5: 4, 6: 1, 7: 3}
for label, samples in label_sample_dict:
self.samp_queue[label] = [Queue(maxsize=samples*ratio), samples]

Error: for label, samples in label_sample_dict:
TypeError: cannot unpack non-iterable int object

Since label_sample_dict is a Python dict iterating it should return the key while you are trying to get two return values. I guess the unpacking then fails. Try to use for key in label_sample_dict and use the key to access the value.

1 Like