0

Why am I getting a name error for 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()
martineau
  • 119,623
  • 25
  • 170
  • 301
Maaz
  • 1

1 Answers1

1

This will work fine

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()