Ask Your Question

Unsure why the 0 values error keeps coming up

asked 2013-06-03 07:06:38 -0500

JoshIzzard gravatar image

updated 2013-06-03 09:15:20 -0500

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 "", line 10, in <module>
    exec compile(u'open("","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("W2ZuYW1lLCBjbmFtZV0gPSBBX2NvbWIycmVwKDMp"),globals())+"\\n"); execfile(os.path.abspath(""))
  File "", line 1, in <module>

  File "/tmp/tmp2u4eia/", 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[1]).degree > bound:
            for v in fw:
                if A(i+1)(k * v).degree() == bound:
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[1] + fw[2]).degree() > bound:
            for j in fw:
                rep = A(i+1)(j+k)
                deg =
                if deg == bound:
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.

Many thanks for your time.

edit retag flag offensive 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 gravatar imagevdelecroix ( 2013-06-03 08:07:14 -0500 )edit

@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

JoshIzzard gravatar imageJoshIzzard ( 2013-06-03 09:18:10 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2013-06-03 09:19:16 -0500

tmonteil gravatar image

updated 2013-06-03 09:25:43 -0500

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.

edit flag offensive delete link more


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

JoshIzzard gravatar imageJoshIzzard ( 2013-06-03 09:26:23 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-06-03 07:06:38 -0500

Seen: 144 times

Last updated: Jun 03 '13