# Unsure why the 0 values error keeps coming up

I am trying to code an algorithm to find the degrees of all small rank representations of $A_n$ that are equal to $p^2$ for some prime $p$. However, I think that my code should be correct, but it keeps giving me the following error:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_24.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("W2ZuYW1lLCBjbmFtZV0gPSBBX2NvbWIycmVwKDMp"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>

File "/tmp/tmp2u4eia/___code___.py", line 3, in <module>
exec compile(u'[fname, cname] = A_comb2rep(_sage_const_3 )
File "", line 1, in <module>

ValueError: need more than 0 values to unpack


The code for which it gives me this error is the following:

def A_comb2rep(p):
bound = p*p
name_fund = []
name_comb = []
A = lambda i: WeylCharacterRing("A{0}".format(i))
for i in range(bound):
for k in range(1,bound+1):
fw = A(i+1).fundamental_weights()
if A(i+1)(k * fw).degree > bound:
break
else:
for v in fw:
if A(i+1)(k * v).degree() == bound:
name_fund.append([])
name_fund[len(name_fund)-1].append('A'+str(i+1)+'('str(k)+str(v)+')')
for i in range(bound): # now onto combinations of two of the fws   #####
for k in fw:
fw = A(i+1).fundamental_weights()
if A(i+1)(fw + fw).degree() > bound:
break
else:
for j in fw:
rep = A(i+1)(j+k)
deg = rep.degree()
if deg == bound:
name_comb.append([])
name_comb[len(name_comb)-1].append('A'+str(i+1)+'['+str(j)+'+'+str(k)+']')
return name_comb, name_fund


A helpful answer would be one that answers: What does ValueError: need more than 0 values to unpack mean and where should I look for tips on how to fix it.

edit retag close merge delete

I do not understand your code. First of all the syntax '('str(k) is not valid (miss a +) and on the other hand "return" appear twice.

@vdelecroix I'm sorry, I was missing a + and I put the return statement that appears halfway down in order to see if the first output of my function was valid but I suppose this is not a correct debugging technique. I have edited the code to fix those two mistakes

Sort by » oldest newest most voted

The problem comes from how you called your function. The function returns an empty list, but you try to assign two variables (fname and cname) with that output.

A simpler example:

sage: def my_empty_func():
sage:     return []
sage: a,b = my_empty_func()
...
ValueError: need more than 0 values to unpack


Here, the error means that you need the function my_empty_func() to return a list (or tuple) of two elements to feed a and b, but it returned a list of zero elements.

more

I see, I just corrected the range that the function needs to access and it worked perfectly. Thanks!