Global Variable With Conditional Logic
Mon 10 August 2026
mode = "light"
def toggle_mode():
global mode
if mode == "light":
mode = "dark"
else:
mode = "light"
toggle_mode()
print(mode) # Output: dark
dark
Score: 10
Category: chapter13_global_and_scope