Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9003049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:39:51+00:00 2026-06-16T00:39:51+00:00

Im not even sure what exactly my problem is from this error. Any information

  • 0

Im not even sure what exactly my problem is from this error. Any information would be very helpful.

what i have so far:

def equations(specie,elements):
vectors=[]
for x in specie: 
    vector=extracting_columns(x,elements)
    vectors.append(vector)

When i run:

 equations(['OH', 'CO2','c3o3','H2O3','CO','C3H1'], 
 ['H', 'C', 'O'])

i get the following error:

    Traceback (most recent call last):
File "<stdin>", line 1, in <module>

File “_sage_input_77.py”, line 10, in
exec compile(u’print support.syseval(python, u”equations([\’OH\’, \’CO2\’,\’c3o3\’,\’H2O3\’,\’CO\’,\’C3H1\’], unel)”, SAGE_TMP_DIR)
File “”, line 1, in

File “/sagenb/sage_install/sage-5.4-sage.math.washington.edu-x86_64-Linux/devel/sagenb-git/sagenb/misc/support.py”, line 479, in syseval
return system.eval(cmd, sage_globals, locals = sage_globals)
File “/sagenb/sage_install/sage-5.4-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/sage/misc/python.py”, line 56, in eval
eval(z, globals)
File “”, line 1, in

File “”, line 4, in equations

File “”, line 3, in extracting_columns

ValueError: need more than 1 value to unpack

my previous functions if needed:
import re
def parse_formula(formula):
”’Given a simple chemical formula, return a list of (element, multiplicity) tuples.

Example:
'H2SO4' --> [('H', 2.0), ('S', 1.0), ('O', 4.0)]


'''

return [ (elem, float(mul) if mul else 1.) for (elem, mul) in re.findall(r'([A-Z][a-z]*)(\d*)', formula) ]

def unique_element(group):
c=[]
for element in group:
piece=parse_formula(element)
for x in piece:
c.append(x[0])

return list(set(c))

def extracting_columns(specie, elements):
species_vector=zeros(len(elements))
for (el,mul) in specie:
species_vector[elements.index(el)]=mul

return species_vector
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:39:52+00:00Added an answer on June 16, 2026 at 12:39 am

    The problem is that you’re calling extracting_columns with a string like 'OH' as the first argument, so when you try to do for (el,mul) in specie: it’s trying to unpack the 'O' into (el, mul).

    An easy way to debug this is to insert a print right before the offending line:

    def extracting_columns(specie, elements):
      species_vector=zeros(len(elements))
      print(specie)
      for (el,mul) in specie:
        species_vector[elements.index(el)]=mul
      return species_vector
    

    So, how is extracting_columns getting 'OH'? Well, let’s look at where it’s called, with a couple more prints:

    def equations(specie,elements):
      vectors=[]
      print(specie)
      for x in specie:
        print(x)
        vector=extracting_columns(x,elements)
        vectors.append(vector)
    

    Now, when you run it, you’ll see that specie is ['OH', 'CO2', 'c3o3', 'H2O3', 'CO', 'C3H1'], so the first element of it is obviously 'OH'.

    As for how to fix this… well, without knowing what you’re actually trying to do, it’s hard to tell you how to do it. But obviously if you want to iterate over the first argument to extracting_columns and treat each item as a pair, you have to pass it a sequence of pairs rather than a string.

    But it looks like your parse_formula is made specifically for turning a string like 'OH' into a list of pairs like [('O', 1.0), ('H', 1.0)]. So presumably the problem is that you just forgot to call it somewhere. Maybe you want equations to look like this?

    def equations(specie, elements):
      vectors=[]
      for x in specie:
        formula = parse_formula(x)
        vector=extracting_columns(formula, elements)
        vectors.append(vector)
    

    This does something, without any exceptions. Whether it’s what you actually want, I have no idea.

    At any rate, learning how to see what’s actually going on in your code and debug trivial problems is probably more important than getting the right answer here immediately.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This problem appears to be intermittent, but I am not sure why exactly. When
I'm not exactly sure how to properly debug this but have tried a few
Not even sure I'm stating the question correctly. Here's the situation. I have a
Not even sure how to explain this but I connect to a remote computer
Im not even sure how to ask this question, but i'll give it a
I'm not even sure how I should phrase this question. I'm passing some CustomStruct
I'm not even sure what this principle is called or how to search for
I'm not even sure what this is called? But I'm trying to learn what
I am not even sure how to ask this question. I want something that
Hello! I'm not even sure if this is possible, but hopefully it is in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.