Nikita Belooussov Nikita Belooussov - 1 year ago 144
Python Question

OrderedDict too many values to unpack

My program is producing:

ValueError: too many values to unpack.

I copied the lines of code that works in other instances.

new_dict = (("data", 0))
new_dict = collections.OrderedDict(new_dict) #the line producing the error

The only difference between this and the other ones that seem to work is that they have more values.

Answer Source
new_dict = (("data", 0))

This is supposed to be a tuple containing key-value pairs. To create a tuple with just one element, add a trailing comma.

new_dict = (("data", 0),)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download