Nikita Belooussov
Nikita Belooussov

Reputation: 606

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.

Upvotes: 1

Views: 1354

Answers (1)

John Kugelman
John Kugelman

Reputation: 361899

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),)

Upvotes: 5

Related Questions