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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:34:24+00:00 2026-06-05T03:34:24+00:00

bit of an issue with a function I’m writing for adding and subtracting a

  • 0

bit of an issue with a function I’m writing for adding and subtracting a value located within a class.

I’m trying to pass a value that I’ve read in from a csv to my add function. This value is a decimal value (e.g. 500.00) I’ve tried eliminating the trailing 0’s to make it just 500, this didn’t work either. I keep getting:

TypeError: add() takes exactly one argument (two given).

Even though I have a print statement confirming its only trying to pass in the 500.

Here’s my function:

def add(amount):
    self.total = self.total + amount

It’s being called by v.add(i) Even if I set i to an arbitray integer value it still results in the same error. I am relatively inexperience with python, so perhaps there is something simple I’m missing here. Thanks.

  • 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-05T03:34:25+00:00Added an answer on June 5, 2026 at 3:34 am
    class Myclass(object):
        def __init__(self, total=0.):
            self.total = total
    
        def add(self, amount):     # <= needs `self` parameter
            self.total += amount
    
    v = Myclass()
    v.add(2.)
    

    When you call an object method, it implicitly passes a reference to the object – so calling v.add(something) actually calls Myclass.add(v, something).

    Voila – two parameters, when you told it to only expect one…

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

Sidebar

Related Questions

I'm having a bit of an issue with a query and scaling that query
I have a bit of an issue with a toggle visibility function which operates
I am trying to make a function return data from an ajax call that
I'm having a small issue with a bit of jQuery: function getQuickResults(terms) { var
I am having a bit of an issue with my _callback function: What I
I am having an issue with the following bit of code. I'm trying to
I've taken a bit of a memcache script that i've used previously without issue,
Having a bit of an issue please see the following code: window.onload = function
I am trying to write a function in C that will shift out the
I'm having a bit of an issue trying to get some PHP code to

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.