Global Keyword

0

Global Keyword

  • Global keyword is a keyword that allows a user to modify a variable outside of the current scope. It is used to create global variables from a non-global scope.

  • We can use global keyword for the following 2 purposes:

  1. To declare global variable inside function 

  2. To make global variable available to the function so that we can perform required modifications.

Note: If global variable and local variable having the same name then we can access global variable inside a function as follows.

Passing a Group of Elements to a Function

  • To pass a group of elements like numbers or strings, we can accept them into a list and then pass the list to the function where the required processing can be done.

 

Post a Comment

0Comments
Post a Comment (0)