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 8993295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:09:47+00:00 2026-06-15T23:09:47+00:00

this is what i have so far: def unique_element(group): list=[] for element in group:

  • 0

this is what i have so far:

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


  return list #list(set(list)) 

I have the other function below but this is the one I am trying to fix. Right now it returns a function with a list of letters but I do not want repeating letters. Example:

unique_element(['H2O2Y2','R3O2','Y2S3'])
['H', 'O', 'Y', 'R', 'O', 'Y', 'S']

I thought using list(set(list)) would work but when i run the function i get:

unique_element(['H2O2Y2','R3O2','Y2S3'])

Traceback (most recent call last):

File "<stdin>", line 1, in <module>
File "_sage_input_61.py", line 10, in <module>
  exec compile(u'print _support_.syseval(python, u"unique_element([\'H2O2Y2\',\'R3O2\',\'Y2S3\'])", __SAGE_TMP_DIR__)
File "", line 1, in <module>

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 <module>

File "", line 10, in unique_element

TypeError: 'list' object is not callable

other functions:

    from numpy import *
    from scipy import *
    from pylab import *
    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) ]
  • 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-15T23:09:49+00:00Added an answer on June 15, 2026 at 11:09 pm

    You are using a standard library function as a variable name. That is why the set() operation is failing.

    Change list = [] to my_list = [] or something else…

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

Sidebar

Related Questions

This is what I have so far: def get_concrete_name_of_class(klass): Given a class return the
Here's what I have so far: def is_ordered(collection): if isinstance(collection, set): return False if
So far i have this, which prints out every word in my list, but
I have this so far but the Column 'name' is ambiguous, so I want
I have this so far but I don't know how to write over the
I have this so far: http://jsfiddle.net/u5vhS/54/ . What I want to be able to
So far i have this: mov ah,02h mov cl,11001100001111011101000b ;6,692,584 in dec mov dl,0
I'm using the javascript module pattern, and have this so far: var APP; if(APP
Thanks to everyone out there helping newbies like me. So far I have this:
This is what I have so far: [my1@graf home]$ curl -# -o f1.flv 'http://osr.com/f1.flv'

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.