im trying to create a bank account data type. i have the following code:

Code:
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)
at this point it ends when running with the following error: local variable 'bal' referenced before assignment

can anyone help??

thank you

GTJ