为什么我收到pays_bill
的名称错误?
error: NameError: name 'pays_bill' is not defined
class Customer:
def __init__(self,total):
self.billamt=total
def pays_bill(self,amount):
print("maaz pays bill amount of Rs.",amount)
def purchases(self):
discount=(.05*self.billamt)
amount=(self.billamt-discount)
pays_bill(self,amount)
x=Customer(1000)
x.purchases()
答案 0 :(得分:1)
这会很好
class Customer:
def __init__(self,total):
self.billamt=total
def pays_bill(self,amount):
print("maaz pays bill amount of Rs.",amount)
def purchases(self):
discount=(.05*self.billamt)
amount=(self.billamt-discount)
self.pays_bill(amount)
x=Customer(1000)
x.purchases()