x = 10 class myClass1(): global x # This takes the variable x outside this class
Here is what the above code is Doing:
1. We create a global variable x.
2. We create a class myClass1.
3. We create a global variable x inside the class.
4. We access the global variable x inside the class.
The output of the code is:
As you can see, the global variable x is accessible inside the class.