How to use globals() in Python

globals() return a dictionary of all global variables. These are variables with global scope which means that they are accessible everywhere in a program.

Solution for How to use globals() in Python : You can use globals() with a variable name as a key globals() returns a dictionary with the keys set as strings of the names of the global variables and the values set as the values of the global variables. Call variable in globals() to return true if variable is a global variable and false if it is not a global variable. Call globals()[“variable”] to return the value of variable if variable is global.