A global variable is a variable that you can use from any part of a program, including within functions. Using global variables inside your Python functions can be tricky. You’ll need to differentiate between accessing and changing the values of the target global variable if you want your code to work correctly.
Global variables can play a fundamental role in many software projects because they enable data sharing across an entire program. However, you should use them judiciously to avoid issues.
In this video course, you’ll:
Understand global variables and how they work in Python
Access global variables within your Python functions directly
Modify and create global variables within functions using the global keyword
Access, create, and modify global variables within your functions with the globals() function
Explore strategies to avoid using global variables in Python code
What’s Included:
Downloadable Resources: