How to change a global variable in a function in Python

A global variable is a variable defined outside of a function. By default, a function cannot change a global variable.

Solution for How to change a global variable in a function in Python : You can use the global keyword to change a global variable in a function Use the global keyword to assign to a global variable.


how-to-change-a-global-variable-in-a-function-in-python