#NEITHER LOCAL NOR GLOBAL --> NON LOCAL KEYWORD ---> UNIQUE FOR PYTHON NESTED LOOPS

global x                              #global variable x
x="hi"
print(x)

def cover():                          #outer loop cover x="welcome"
	x="welcome"
	
	def book():                       #inner loop book x="hello"
		nonlocal x                    #nonlocal variable x defines the scope that's neither local nor global
		x="hello"                      
		print("inner loop:"+ x)
		
	book()                           #calling inner loop prints hello
	print("outer loop:"+x)           #local variable's value is still hello
	
cover()                              #calling outer loop


'''OUTPUT:

stud@HP-246-Notebook-PC:~$ python abi4.py
hi
inner loop:hello
outer loop:hello

#########IMPORTANT NOTE: OUTPUT WITHOUT USING NONLOCAL KEYWORD###########

stud@HP-246-Notebook-PC:~$ python abi4.py
hi
inner loop:hello
outer loop:welcome
'''




	
bfb96f533c409292ffe897b649ff40d738b42a8a
<mask token>

<mask token>


def cover():
    x = 'welcome'

    def book():
        nonlocal x
        x = 'hello'
        print('inner loop:' + x)
    book()
    print('outer loop:' + x)


<mask token>

global x
<mask token>
print(x)


def cover():
    x = 'welcome'

    def book():
        nonlocal x
        x = 'hello'
        print('inner loop:' + x)
    book()
    print('outer loop:' + x)


cover()
<mask token>

global x
x = 'hi'
print(x)


def cover():
    x = 'welcome'

    def book():
        nonlocal x
        x = 'hello'
        print('inner loop:' + x)
    book()
    print('outer loop:' + x)


cover()
<mask token>

#NEITHER LOCAL NOR GLOBAL --> NON LOCAL KEYWORD ---> UNIQUE FOR PYTHON NESTED LOOPS

global x                              #global variable x
x="hi"
print(x)

def cover():                          #outer loop cover x="welcome"
	x="welcome"
	
	def book():                       #inner loop book x="hello"
		nonlocal x                    #nonlocal variable x defines the scope that's neither local nor global
		x="hello"                      
		print("inner loop:"+ x)
		
	book()                           #calling inner loop prints hello
	print("outer loop:"+x)           #local variable's value is still hello
	
cover()                              #calling outer loop


'''OUTPUT:

stud@HP-246-Notebook-PC:~$ python abi4.py
hi
inner loop:hello
outer loop:hello

#########IMPORTANT NOTE: OUTPUT WITHOUT USING NONLOCAL KEYWORD###########

stud@HP-246-Notebook-PC:~$ python abi4.py
hi
inner loop:hello
outer loop:welcome
'''




	