what is the difference between global and non local keywords In python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

what is the difference between global and non local keywords In python

19th Aug 2020, 3:53 AM
Sangeetha
8 Answers
+ 2
Nonlocal variables are used in nested functions whose local scope is not defined. This means that the variable can be neither in the local nor the global scope. For more information please visit-: https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/ref_keyword_nonlocal.asp
19th Aug 2020, 4:04 AM
Akash Agrawal
Akash Agrawal - avatar
+ 1
Akash Agrawal thanks for helping me it really helps
19th Aug 2020, 4:18 AM
Sangeetha
+ 1
The nonlocal statement does to enclosing scope variable what global statement does to the global variable. The nonlocal is a counterpat of the global statement. Afer calling func() the value of 'gb' and 'esv' are changed even outisde the local scope.
19th Aug 2020, 1:28 PM
Priya Sharma :)
Priya Sharma :) - avatar
0
thanks for your response.... but I am not asking between global and local variables.. I need difference between global and nonlocal keywords I hope u understand my qns
19th Aug 2020, 4:06 AM
Sangeetha
0
Kon
19th Aug 2020, 3:58 PM
Neelam Pandey
Neelam Pandey - avatar
- 1
Ok
19th Aug 2020, 5:01 AM
Neelam Pandey
Neelam Pandey - avatar
- 1
Kab rat ko ha free
19th Aug 2020, 5:01 AM
Neelam Pandey
Neelam Pandey - avatar
- 1
Ashutosh
19th Aug 2020, 5:16 AM
Neelam Pandey
Neelam Pandey - avatar