+ 2

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

19th Aug 2020, 3:53 AM
Sangeetha
9 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