Escaping the local bubble

Report a typo

How can you modify the given code to make the increment_counter() function correctly update and display the global counter variable?

Fill in the gaps with the relevant elements
counter = 0
 increment_counter():
     counter
    counter += 1
    (f"Counter value: {counter}")
increment_counter()
increment_counter()
print(f"Final counter value: {counter}")
printreturndeflocalclassglobal

Create a free account to access the full topic