Shared Cells Across Sibling Closures
def make_account(balance):
def deposit(amount):
nonlocal balance
balance += amount
return balance
def withdraw(amount):
nonlocal balance
balance -= amount
return balance
def get_balance():
return balance
return deposit, withdraw, get_balance
dep1, wd1, bal1 = make_account(100)
dep2, wd2, bal2 = make_account(100)
dep1(50)
wd1(20)
Select all that apply.
Sign in to answer questions and track your progress
Sign In