Python 101 : Local and Global variable - locals(), globals() -

Sometimes, we lose track of our variables inside big chunks of code.

Python gives us the possibility to display variables depending on their namespace and scope.

The locals() function returns a dictionary with the variables that are in the local namespace, while the globals() function returns a dictionary with the variables that live in the global namespace.

Below is an example that illustrates that:


Leave as a comment: