globalIntermediate Playground

Declares a variable inside a function as belonging to the global scope

Python Playground
Output
Click "Run" to execute your code

Classes and closures are almost always better than global variables. They allow multiple independent instances and are easier to test.

Challenge

Try modifying the code above to explore different behaviors. Can you extend the example to handle a new use case?