Reputation: 2185
I was writing the following code to create a dictionary:
for a,b,c in foo:
d=float(a or 0)-float(b or 0)
bar[c]=d
print bar
This works but gives me bar over and over. However when I try to use bar outside the for loop, i get the following error;
ValueError: need more than 1 value to unpack
Upvotes: 2
Views: 1922
Reputation: 17981
That error message means you are trying to store one value in a tuple that requires more than one value.
>>>(x,y,z) = [5]
ValueError: need more than 1 value to unpack
You should look for somewhere in your code where you are assigning to a tuple. It seems that foo
is a list of tuples. Maybe you are trying to assign something to an element of foo
Upvotes: 2