Python: ValueError: too many values to unpack

eg1:

>> >> a,b=(1,2,3)

Traceback (most recent call last):

& & lt; stdin>, line 1,in < module>

ValueError: too many values to unpack (expected 2)

ERROR: a tuple value is 32473; when a tuple variable, the number is not the product

can change a,b,c=(1,2,3) or other variables

eg2:

>> >> Import collections

>> >> s=[(‘y’,1), (‘b’,1), (‘r’),(‘y’,2)]

>> >> d=collections.defaultdict(list)

>> >> for k,v in s:

…obey[k].append(v)

Traceback (most recent call last):

& & lt; stdin>, line 1,in < module>

ValueError: too many values to unpack (expected 2)

ERROR: s=[(‘y’,1),(‘b’,1),(‘r’),(‘y’,2)] The number of values in this string (‘r’) is not valid

can change s=[(‘y’,1), (‘b’,1), (‘r’,1), (‘y’,2)] or other values

Similar Posts: