On Jul 2, 2016 9:00 PM, <cadenmr...@gmail.com> wrote: > > When i run the code I get this error : > Traceback (most recent call last): > File "C:/Python25/chapter2", line 18, in <module> > bank=InterestAccount(5,1000,0.5) > NameError: name 'InterestAccount' is not defined > > I can't find the issue, any help?
Following is voice dictated therefore not actually correct but you'll get the point . interest account is a nested class inside of class bank account you're trying to refer to it outside of class > > > class BankAccount: > def __init__(self,numb,bal): > self.numb = numb > self.bal = bal > def showbal(self): > print "Your balance is", self.bal > def withdraw(self,wa): > self.bal-=wa > print("Your balance is now", self.bal) > def deposit(self,da): > bal+=da > print("Your balance is now", self.bal) > class InterestAccount(): > def BankAccount__init__(self,numb,bal,intrate): > self.intrate=intrate > def addintrest(self): > self.bal = self.bal * self.intrate > bank=InterestAccount(5,1000,0.5) > bank.addintrest() > bank.showbal() > > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list