global — Expert Playground
Declares a variable inside a function as belonging to the global scope
Python Playground
Output
Click "Run" to execute your codeGlobal reads use LOAD_GLOBAL, global writes use STORE_GLOBAL. Local variables use LOAD_FAST/STORE_FAST which are faster because they use indexed array access instead of dict lookup.
Challenge
Try modifying the code above to explore different behaviors. Can you extend the example to handle a new use case?