?? Day43 of #100DaysOfPython ??
Today, we're diving into Local & Global variables in python!
Local variables are defined within a function or block and have a limited scope, accessible only within the function or block where they are defined.
Global variables are defined outside of all functions or blocks and have a broader scope, accessible throughout the entire program.
Local variables exist only during the function's execution, while global variables remain in memory for the duration of the program.
Let's go through a demonstration of local and global variable in python below:
When the global keyword is used (such as in the function above), the variable belongs to the global scope, enabling changes to global variables inside a function.
Stay tuned for more demonstrations in python!