How do we access a global variable in nested functions?
How do we access a global variable in nested functions? Correct Answer Declare the variable as global
Any global variable, in the primary function, if required to be accessed by a nested function- the variable needs to be declared with the global keyword within the function which requires access to it. This allows sharing the variable amongst the primary and other functions. If the variable is declared without using the global keyword, the variable might bring an error to the function.
মোঃ আরিফুল ইসলাম
Feb 20, 2025