Allows you to modify the variable outside of the current scope.

It is used to create a global variable and make changes to the variable in a local context.

Rules of global Keyword

  1. When we create a variable inside a function, it is local by default.
  2. When we define a variable outside of a function, it is global by default. You don't have to use global keyword.
  3. We use global keyword to read and write a global variable inside a function.
  4. Use of global keyword outside a function has no effect.