im trying to create a bank account data type. i have the following code:
at this point it ends when running with the following error: local variable 'bal' referenced before assignmentCode:def bankAccount(): bal=0 def credit(amount): bal=bal+amount def debit(amount): bal=bal-amount def balance(): return bal return (lambda x: {"credit":credit, "debit":debit, "balance":balance }[x]) b=bankAccount() print b("balance")() b("credit")(100)
can anyone help??
thank you
GTJ




Reply With Quote