I can not understand why the code does not work. Inheritance. Please do not just write the answer, but briefly explain that such questions no longer arise!
class BankAccount: def __init__(self, name, number_count): self.name = name self.number_count = number_count self.count_condition = 0.0 self.valid_count = 328475 def showCount(self, number_count): if self.number_count == self.valid_count: return round(self.count_condition, 1) else: return "Wrong count number!" def addMoney(self, number_count, money_count): if self.number_count == self.valid_count: self.count_condition += money_count else: return "Error!" def minusMoney(self, number_count, money_count): if self.number_count == self.valid_count: self.count_condition -= money_count else: return "Error!" class InterestAccount(BankAccount): def addInterest(self, procent): if self.count_condition > 0: return (BankAccount.count_condition / 100) * self.procent myCount = BankAccount("One", 328475) myCount.addMoney(328475, 45.5) print(myCount.showCount(328475)) myCount.minusMoney(328475, 1.3) print(myCount.showCount(328475)) myProcent = InterestAccount("One", 328475) print(myProcent.addInterest(7)) Conclusion :
45.5 44.2 None
count_conditionandvalid_countstatic in theBankAccountclass - Maxim Timakov