Python Forum

Full Version: Getting the error like function not defined .. suggest correct code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
class ABC:
    def __init__(self,name,accno):
        self.name=name
        self.accno=accno
   
    def main(self):
        print("Welcome to ABC bank , we care for you")
        print("Exciting offers , Loans , Gold schemes and Interest Rates awaits for you")
        trans='y'
        while trans=='y':
            t=input("deposit r withdraw?: ")
            
            if t=='w':
                withdraw()
            if t=='d':
                deposit()
            else:
                print("wrong selection try again")
            trans=input("Any other transaction?")
    def deposit(self):
        balance=0.0
        amount=int(input("enter the amount to deposit"))
        balance+=amount
        print('the balance is',balance)
    def withdraw(self):
        balance=0.0
        amount=int(input("enter the amount to deposit"))
        balance-=amount
        print("the balance is",balance)
c1=ABC("RAGHAVA",1000123)
c1.main()
I get prompted with input when I run your code, no error. Generally, you should provide complete instructions (e.g. input to reproduce) and not expect us to figure it out for you.

More than that, I suggest you simplify your code. Don't require us to input anything to your code unless it's absolutely required. Hard-code the relevant value(s) instead.