Skip to main content
Made modest grammar and formatting improvements.
Source Link
DavidRR
  • 19.8k
  • 27
  • 114
  • 202

I currently haveimplementing a class set up called Bank AccountBankAccount. It allows meoffers the ability to set a balancebalance, depositmake a deposit, withdrawmake a withdrawal, and check the balancecheck the balance.

Now I have to write a function (called processAccounts()) that will take the name of a file as its parameter. The first line of the file will be a number which specified the initial bank account balance. The lines that follow will specify a series of withdrawals and deposits marked by w or W for withdrawals and d or D for deposits. The function must read the the text file, set the initial balance, and then make withdrawals or deposits based on the contents of the text file.

Here is what I have so far:

class BankAccount:

    def set(self,balance=0):
        self.balance=balance        
    def deposit(self,amount):
        self.balance += amount
    def withdraw(self,amount):
        self.balance -= amount
    def get_balance(self):
        return self.balance
def processAccounts(fname):
    with open(fname,'r') as f:
    acct=[]
    for line in f:
        line=line.split()
        if line:
            line= [int(i) for i in line]
            acct.set(line)

Text File:

1000.00
W 50.50
W 5.25
d 100.75
w 525.15
d 85.70

I am currently trying to set up the first part which will read the first line and then call upon the set() function to set the initial balance.

The error I'm getting is:

ValueError: invalid literal for int() with base 10: '1000.00'

Am I approaching this problem incorrectly or did I just not do it correctly?

I currently have a class set up called Bank Account. It allows me to set a balance, deposit, withdraw, and check the balance.

Now I have to write a function (called processAccounts()) that will take the name of a file as its parameter. The first line of the file will be a number which specified the initial bank account balance. The lines that follow will specify a series of withdrawals and deposits marked by w or W for withdrawals and d or D for deposits. The function must read the the text file, set the initial balance, and then make withdrawals or deposits based on the contents of the text file.

Here is what I have so far:

class BankAccount:

    def set(self,balance=0):
        self.balance=balance        
    def deposit(self,amount):
        self.balance += amount
    def withdraw(self,amount):
        self.balance -= amount
    def get_balance(self):
        return self.balance
def processAccounts(fname):
    with open(fname,'r') as f:
    acct=[]
    for line in f:
        line=line.split()
        if line:
            line= [int(i) for i in line]
            acct.set(line)

Text File:

1000.00
W 50.50
W 5.25
d 100.75
w 525.15
d 85.70

I am currently trying to set up the first part which will read the first line and then call upon the set() function to set the initial balance.

The error I'm getting is:

ValueError: invalid literal for int() with base 10: '1000.00'

Am I approaching this problem incorrectly or did I just not do it correctly?

I currently implementing a class called BankAccount. It offers the ability to set a balance, make a deposit, make a withdrawal, and check the balance.

Now I have to write a function (called processAccounts()) that will take the name of a file as its parameter. The first line of the file will be a number which specified the initial bank account balance. The lines that follow will specify a series of withdrawals and deposits marked by w or W for withdrawals and d or D for deposits. The function must read the the text file, set the initial balance, and then make withdrawals or deposits based on the contents of the text file.

Here is what I have so far:

class BankAccount:

    def set(self,balance=0):
        self.balance=balance        
    def deposit(self,amount):
        self.balance += amount
    def withdraw(self,amount):
        self.balance -= amount
    def get_balance(self):
        return self.balance
def processAccounts(fname):
    with open(fname,'r') as f:
    acct=[]
    for line in f:
        line=line.split()
        if line:
            line= [int(i) for i in line]
            acct.set(line)

Text File:

1000.00
W 50.50
W 5.25
d 100.75
w 525.15
d 85.70

I am currently trying to set up the first part which will read the first line and then call upon the set() function to set the initial balance.

The error I'm getting is:

ValueError: invalid literal for int() with base 10: '1000.00'

Am I approaching this problem incorrectly or did I just not do it correctly?

I currently have a class set up called Bank AccountBank Account. It allows me to set a balancebalance, depositdeposit, withdrawwithdraw, and check the balancecheck the balance.

Now I have to write a function (called processAccounts()) that will take the name of a file as its parameter. The first line of the file will be a number which specified the initial bank account balance. The lines that follow will specify a series of withdrawals and deposits marked by 'w'w or 'W'W for withdrawals and 'd'd or 'D'D for deposits. The function must read the the text file, set the initial balance, and then make withdrawals or deposits based on the contents of the text file.

Here is what I have so far:

class BankAccount:

    def set(self,balance=0):
        self.balance=balance        
    def deposit(self,amount):
        self.balance += amount
    def withdraw(self,amount):
        self.balance -= amount
    def get_balance(self):
        return self.balance
def processAccounts(fname):
    with open(fname,'r') as f:
    acct=[]
    for line in f:
        line=line.split()
        if line:
            line= [int(i) for i in line]
            acct.set(line)

Text File:

1000.00
W 50.50
W 5.25
d 100.75
w 525.15
d 85.70

I am currently trying to set up the first part which will read the first line and then call upon the set()set() function to set the initial balance.

The error I'm getting is:

ValueError: invalid literal for int() with base 10: '1000.00'

Am I approaching this problem incorrectly or did I just not do it correctly?

I currently have a class set up called Bank Account. It allows me to set a balance, deposit, withdraw, and check the balance.

Now I have to write a function (called processAccounts()) that will take the name of a file as its parameter. The first line of the file will be a number which specified the initial bank account balance. The lines that follow will specify a series of withdrawals and deposits marked by 'w' or 'W' for withdrawals and 'd' or 'D' for deposits. The function must read the the text file, set the initial balance, and then make withdrawals or deposits based on the contents of the text file.

Here is what I have so far:

class BankAccount:

    def set(self,balance=0):
        self.balance=balance        
    def deposit(self,amount):
        self.balance += amount
    def withdraw(self,amount):
        self.balance -= amount
    def get_balance(self):
        return self.balance
def processAccounts(fname):
    with open(fname,'r') as f:
    acct=[]
    for line in f:
        line=line.split()
        if line:
            line= [int(i) for i in line]
            acct.set(line)

Text File:

1000.00
W 50.50
W 5.25
d 100.75
w 525.15
d 85.70

I am currently trying to set up the first part which will read the first line and then call upon the set() function to set the initial balance.

The error I'm getting is:

ValueError: invalid literal for int() with base 10: '1000.00'

Am I approaching this problem incorrectly or did I just not do it correctly?

I currently have a class set up called Bank Account. It allows me to set a balance, deposit, withdraw, and check the balance.

Now I have to write a function (called processAccounts()) that will take the name of a file as its parameter. The first line of the file will be a number which specified the initial bank account balance. The lines that follow will specify a series of withdrawals and deposits marked by w or W for withdrawals and d or D for deposits. The function must read the the text file, set the initial balance, and then make withdrawals or deposits based on the contents of the text file.

Here is what I have so far:

class BankAccount:

    def set(self,balance=0):
        self.balance=balance        
    def deposit(self,amount):
        self.balance += amount
    def withdraw(self,amount):
        self.balance -= amount
    def get_balance(self):
        return self.balance
def processAccounts(fname):
    with open(fname,'r') as f:
    acct=[]
    for line in f:
        line=line.split()
        if line:
            line= [int(i) for i in line]
            acct.set(line)

Text File:

1000.00
W 50.50
W 5.25
d 100.75
w 525.15
d 85.70

I am currently trying to set up the first part which will read the first line and then call upon the set() function to set the initial balance.

The error I'm getting is:

ValueError: invalid literal for int() with base 10: '1000.00'

Am I approaching this problem incorrectly or did I just not do it correctly?

Improved title and made modest grammar improvements.
Source Link
DavidRR
  • 19.8k
  • 27
  • 114
  • 202

I currently have a class set up called Bank Account. It allows me to set a balance, deposit, withdraw, and check the balance.

Now I have to write a function(processAccoutns  ()called processAccounts()) that will take the name of a file as its parameter. The first line of the file will be a number which it setsspecified the Initialinitial bank account balance to then the following. The lines that follow will bespecify a series of withdrawals and deposits marked by 'w' or 'W' for withdrawals and 'd' or 'D' for deposits. The function must read the lines andthe text file, set the initial balance, and then make withdrawals or deposits based on the contents of the text file.

Here is what I have so far:

class BankAccount:

    def set(self,balance=0):
        self.balance=balance        
    def deposit(self,amount):
        self.balance += amount
    def withdraw(self,amount):
        self.balance -= amount
    def get_balance(self):
        return self.balance
def processAccounts(fname):
    with open(fname,'r') as f:
    acct=[]
    for line in f:
        line=line.split()
        if line:
            line= [int(i) for i in line]
            acct.set(line)

Text File:

1000.00
W 50.50
W 5.25
d 100.75
w 525.15
d 85.70
1000.00
W 50.50
W 5.25
d 100.75
w 525.15
d 85.70

I am currently trying to set up the first part which will read the first line and then call upon the set() function to set the initial balance.

The error I'm getting is:

ValueError: invalid literal for int() with base 10: '1000.00'

Am I approaching this problem incorrectly or did I just not do it correctly?

I currently have a class set up called Bank Account. It allows me to set a balance, deposit, withdraw, and check the balance.

Now I have to write a function(processAccoutns()) that will take the name of a file as its parameter. The first line of the file will be a number which it sets the Initial bank account balance to then the following will be a series of withdrawals and deposits marked by 'w' or 'W' for withdrawals and 'd' or 'D' for deposits. The function must read the lines and set the initial balance then make withdrawals or deposits based on text file.

class BankAccount:

    def set(self,balance=0):
        self.balance=balance        
    def deposit(self,amount):
        self.balance += amount
    def withdraw(self,amount):
        self.balance -= amount
    def get_balance(self):
        return self.balance
def processAccounts(fname):
    with open(fname,'r') as f:
    acct=[]
    for line in f:
        line=line.split()
        if line:
            line= [int(i) for i in line]
            acct.set(line)

Text File:

1000.00
W 50.50
W 5.25
d 100.75
w 525.15
d 85.70

I am currently trying to set up the first part which will read the first line and then call upon the set() function to set the initial balance.

The error I'm getting is:

ValueError: invalid literal for int() with base 10: '1000.00'

Am I approaching this problem incorrectly or did I just not do it correctly?

I currently have a class set up called Bank Account. It allows me to set a balance, deposit, withdraw, and check the balance.

Now I have to write a function  (called processAccounts()) that will take the name of a file as its parameter. The first line of the file will be a number which specified the initial bank account balance. The lines that follow will specify a series of withdrawals and deposits marked by 'w' or 'W' for withdrawals and 'd' or 'D' for deposits. The function must read the the text file, set the initial balance, and then make withdrawals or deposits based on the contents of the text file.

Here is what I have so far:

class BankAccount:

    def set(self,balance=0):
        self.balance=balance        
    def deposit(self,amount):
        self.balance += amount
    def withdraw(self,amount):
        self.balance -= amount
    def get_balance(self):
        return self.balance
def processAccounts(fname):
    with open(fname,'r') as f:
    acct=[]
    for line in f:
        line=line.split()
        if line:
            line= [int(i) for i in line]
            acct.set(line)

Text File:

1000.00
W 50.50
W 5.25
d 100.75
w 525.15
d 85.70

I am currently trying to set up the first part which will read the first line and then call upon the set() function to set the initial balance.

The error I'm getting is:

ValueError: invalid literal for int() with base 10: '1000.00'

Am I approaching this problem incorrectly or did I just not do it correctly?

Loading
Source Link
iggyami
  • 43
  • 1
  • 6
Loading