globalEasy Playground

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

Python Playground
Output
Click "Run" to execute your code

Without 'global', assigning to a variable inside a function creates a local variable. 'global' tells Python to use the module-level variable instead.

Challenge

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