+ 2
What is global and local variables
2 Respostas
+ 4
https://code.sololearn.com/c5a3zTNVrnyW/#py
Lessons:
- Variables declared outside functions can be read in functions (they're globally-available), unless the function sets a variable by the same name...making that name local to the function (note the Exception).
- To set the global variable (which would otherwise immediately be local) you must declare your intention to set it with the word 'global'.
+ 1
Simply:
A global variable is a variable that can be accessed anywhere in the code - any function etc.
A local variable is a variable that is 'exclusive' to that specific function, and can only be accessed within it- unless the value is returned...
HOPE THIS HELPS!