Challenge 1
Complete the nested function so it prints the enclosing function value.
def outer():
topic = "scopes"
def inner():
inner()
outer()
Press Ctrl⌘Enter to check your answer
Practice local name resolution, global rebinding, and nonlocal rebinding.
Challenge 1
def outer():
topic = "scopes"
def inner():
inner()
outer()
Press Ctrl⌘Enter to check your answer
Challenge 2
count = 0
def increase():
count += 1
increase()
print(count)
Press Ctrl⌘Enter to check your answer
Challenge 3
def make_counter():
count = 0
def next_count():
count += 1
return count
return next_count
counter = make_counter()
print(counter())
Press Ctrl⌘Enter to check your answer
Challenge 4
count = 10
def show_count():
show_count()
Press Ctrl⌘Enter to check your answer
Challenge 5
def add_bonus():
return total
print(add_bonus())
Press Ctrl⌘Enter to check your answer