global — Advanced Playground
Declares a variable inside a function as belonging to the global scope
Python Playground
Output
Click "Run" to execute your codeglobals() returns the module's namespace dict. Variables declared with 'global' modify this dict. You can also add variables dynamically via globals()['name'] = value.
Challenge
Try modifying the code above to explore different behaviors. Can you extend the example to handle a new use case?