Click here to Skip to main content
15,889,889 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I tired to make a bank in which one can deposit and withdraw funds , but i am getting a type error

Here is the code:

Python
class Account():
    def __init__(self, name, balance, min_balance):
    
      self.name = name
      self.balance = balance
      self.min_balance = min_balance 

   
    def Deposit(self,amount):
        self.balance += amount


    def with_draw(self,amount):
        if self.balance - amount >= self.min_balance:
            self.balance - amount
        else:
            print("Sorry you have reached you,r minimum balance")   


    
    def Statement(self):
        print(f"You,r Current balance is {self.balance}")





class Current(Account):
    def __init__(self, name, balance):
        super().__init__(self, name, balance, min_balance = -1000)





HERE IS THE ERROR:
TypeError: __init__() got multiple values for argument 'min_balance'

What I have tried:

i googled the oproblem , i tried to give the minimum balance no value in the code but then when i write like x = Current("ubaid",50,10)
i insert the value of min balance in interpreter but it gives an error

TypeError: __init__() takes 3 positional arguments but 4 were given
Posted
Updated 18-Dec-18 0:54am
v2

1 solution

You are using an extra parameter (self) in your call to super().__init__. It should be just:
Python
class Current(Account):
    def __init__(self, name, balance):
        super().__init__(name, balance, min_balance = -1000)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900